修复出库时候找不到名称等问题
This commit is contained in:
@ -37,8 +37,8 @@ class BuyInboundService:
|
||||
|
||||
exists = query.first()
|
||||
if exists:
|
||||
# 获取占用该SN的物料名称,提示更友好
|
||||
occupied_name = exists.material.name if exists.material else "未知物料"
|
||||
# [修改] 获取占用该SN的物料名称 (material -> base)
|
||||
occupied_name = exists.base.name if exists.base else "未知物料"
|
||||
raise ValueError(f"序列号【{serial_number}】已存在!被物料 [{occupied_name}] 占用,请核查。")
|
||||
|
||||
# 2. 批号 (BN) 同物料唯一校验
|
||||
@ -309,12 +309,12 @@ class BuyInboundService:
|
||||
d = {
|
||||
'id': item.id,
|
||||
'base_id': item.base_id,
|
||||
# 确保这里从关联的 MaterialBase 获取规格型号
|
||||
'material_name': item.material.name if item.material else '',
|
||||
'spec_model': item.material.spec_model if item.material else '',
|
||||
'category': item.material.category if item.material else '',
|
||||
'unit': item.material.unit if item.material else '',
|
||||
'material_type': item.material.material_type if item.material else '',
|
||||
# [核心修改] 确保这里从关联的 .base 获取信息
|
||||
'material_name': item.base.name if item.base else '',
|
||||
'spec_model': item.base.spec_model if item.base else '',
|
||||
'category': item.base.category if item.base else '',
|
||||
'unit': item.base.unit if item.base else '',
|
||||
'material_type': item.base.material_type if item.base else '',
|
||||
|
||||
'sku': item.sku,
|
||||
'inbound_date': date_display,
|
||||
|
||||
@ -30,7 +30,8 @@ class ProductInboundService:
|
||||
|
||||
exists = query.first()
|
||||
if exists:
|
||||
occupied_name = exists.material.name if (hasattr(exists, 'material') and exists.material) else "未知物料"
|
||||
# [修改] material -> base
|
||||
occupied_name = exists.base.name if (hasattr(exists, 'base') and exists.base) else "未知物料"
|
||||
raise ValueError(f"序列号【{serial_number}】已存在!被成品 [{occupied_name}] 占用,请核查。")
|
||||
|
||||
# ============================================================
|
||||
@ -318,6 +319,7 @@ class ProductInboundService:
|
||||
|
||||
items = []
|
||||
for item in current_items:
|
||||
# [注意] 因为Model层已经修改了 to_dict 内部的 material -> base,所以这里直接调 to_dict 即可
|
||||
d = item.to_dict()
|
||||
|
||||
# 格式化日期
|
||||
|
||||
@ -32,7 +32,8 @@ class SemiInboundService:
|
||||
|
||||
exists = query.first()
|
||||
if exists:
|
||||
occupied_name = exists.material.name if (hasattr(exists, 'material') and exists.material) else "未知物料"
|
||||
# [修改] material -> base
|
||||
occupied_name = exists.base.name if (hasattr(exists, 'base') and exists.base) else "未知物料"
|
||||
raise ValueError(f"序列号【{serial_number}】已存在!被半成品 [{occupied_name}] 占用,请核查。")
|
||||
|
||||
# 2. 批号 (BN) 校验 - 同物料下不能重复开单
|
||||
@ -420,6 +421,7 @@ class SemiInboundService:
|
||||
|
||||
items = []
|
||||
for item in current_items:
|
||||
# [注意] 因为Model层已经修改了 to_dict 内部的 material -> base,所以这里直接调 to_dict 即可
|
||||
d = item.to_dict()
|
||||
|
||||
# 格式化展示日期
|
||||
|
||||
Reference in New Issue
Block a user