修复出库时候找不到名称等问题

This commit is contained in:
dxc
2026-02-10 11:13:07 +08:00
parent bccbeaadce
commit e876505a1b
7 changed files with 49 additions and 40 deletions

View File

@ -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,