diff --git a/app/modules/dispatch/router.py b/app/modules/dispatch/router.py index 96996cb..4c8acf1 100644 --- a/app/modules/dispatch/router.py +++ b/app/modules/dispatch/router.py @@ -448,6 +448,20 @@ async def stock_export( detail += f" (itemcode 리더 오류: {hint})" raise HTTPException(status_code=422, detail=detail) + # 사방넷 코드 맵이 통째로 비어 있으면 A열(상품코드[필수])이 전부 공란이 된다. + # 보통 itemcode_ro 의 single_items/set_items SELECT 권한 누락이 원인. + reader = getattr(request.app.state, "malaysia_itemcode", None) + if getattr(reader, "enabled", False) and not sabangnet_map: + hint = getattr(reader, "last_error", "") or getattr(reader, "reason", "") + detail = ( + "사방넷 코드 맵이 비어 있어 상품코드[필수] 열을 채울 수 없습니다. " + "itemcode_db 의 single_items/set_items 에 sabangnet_code 가 등록돼 있는지, " + "읽기 전용 역할(itemcode_ro)에 두 테이블 SELECT 권한이 있는지 확인하세요." + ) + if hint: + detail += f" (itemcode 리더 오류: {hint})" + raise HTTPException(status_code=422, detail=detail) + xlsx_bytes = export.build_stock_xlsx(rows=rows, set_bom=set_bom, sabangnet_map=sabangnet_map) fname = export.stock_filename(d) headers = {