feat: MaterialBatch 添加字段以支持追踪原料批次5

This commit is contained in:
caoqianming 2024-11-14 10:52:21 +08:00
parent b5928b2927
commit e92ceca953
1 changed files with 12 additions and 2 deletions

View File

@ -113,6 +113,7 @@ def do_in(item: MIOItem):
else:
action_list = [[item.material, item.batch, item.count]]
production_dept = None
for al in action_list:
xmaterial, xbatch, xcount = al
@ -140,13 +141,22 @@ def do_in(item: MIOItem):
else:
raise ParseError(f'{str(xmaterial)}-{xbatch}车间物料不足')
if production_dept is None:
production_dept = wm.mgroup.belong_dept
elif production_dept != wm.mgroup.belong_dept:
raise ParseError(f'{str(xmaterial)}-{xbatch}车间物料不属于同一车间')
# 增加mb
if not is_zhj:
mb, _ = MaterialBatch.objects.get(
material=xmaterial,
warehouse=item.warehouse,
batch=xbatch,
defaults={"count": 0, "batch_ofrom": wm.batch_ofrom, "material_ofrom": xmaterial}
defaults={
"count": 0,
"batch_ofrom": wm.batch_ofrom,
"material_ofrom": xmaterial,
"production_dept": production_dept
}
)
mb.count = mb.count + xcount
mb.save()
@ -157,7 +167,7 @@ def do_in(item: MIOItem):
material=item.material,
warehouse=item.warehouse,
batch=item.batch,
defaults={"count": 0}
defaults={"count": 0, "production_dept": production_dept}
)
if not is_created:
raise ParseError("该批次组合件已存在")