This commit is contained in:
2026-03-18 00:21:43 +08:00
parent 434bc59266
commit 7964ce1033
2 changed files with 11 additions and 6 deletions
+7 -2
View File
@@ -204,7 +204,12 @@ async def _issue_materials_for_order_creation(
warehouse = await _get_default_warehouse(db_session)
plan_items, planned_material_cost = await _build_material_plan(db_session, order)
if not plan_items:
raise HTTPException(status_code=400, detail="销售单产品未配置物料BOM,无法自动扣减物料")
order.production_no = order.production_no or generate_order_no("WO")
order.production_status = "bom_missing"
order.planned_material_cost = 0
order.actual_material_cost = 0
order.status = "manufacturing"
return 0, 0, 0
shortage_items = [item for item in plan_items if item.shortage_quantity > 0]
if shortage_items:
shortage_text = ",".join([f"{item.material_name} 缺 {item.shortage_quantity}" for item in shortage_items])
@@ -252,7 +257,7 @@ async def _issue_materials_for_order_creation(
order.production_status = "material_issued"
order.planned_material_cost = round(float(planned_material_cost), 4)
order.actual_material_cost = round(float(actual_material_cost), 4)
order.status = "pending"
order.status = "manufacturing"
return movement_count, planned_material_cost, actual_material_cost