feat: MaterialBatch 添加字段以支持追踪原料批次5
This commit is contained in:
parent
b5928b2927
commit
e92ceca953
|
@ -113,6 +113,7 @@ def do_in(item: MIOItem):
|
||||||
else:
|
else:
|
||||||
action_list = [[item.material, item.batch, item.count]]
|
action_list = [[item.material, item.batch, item.count]]
|
||||||
|
|
||||||
|
production_dept = None
|
||||||
for al in action_list:
|
for al in action_list:
|
||||||
xmaterial, xbatch, xcount = al
|
xmaterial, xbatch, xcount = al
|
||||||
|
|
||||||
|
@ -140,13 +141,22 @@ def do_in(item: MIOItem):
|
||||||
else:
|
else:
|
||||||
raise ParseError(f'{str(xmaterial)}-{xbatch}车间物料不足')
|
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
|
# 增加mb
|
||||||
if not is_zhj:
|
if not is_zhj:
|
||||||
mb, _ = MaterialBatch.objects.get(
|
mb, _ = MaterialBatch.objects.get(
|
||||||
material=xmaterial,
|
material=xmaterial,
|
||||||
warehouse=item.warehouse,
|
warehouse=item.warehouse,
|
||||||
batch=xbatch,
|
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.count = mb.count + xcount
|
||||||
mb.save()
|
mb.save()
|
||||||
|
@ -157,7 +167,7 @@ def do_in(item: MIOItem):
|
||||||
material=item.material,
|
material=item.material,
|
||||||
warehouse=item.warehouse,
|
warehouse=item.warehouse,
|
||||||
batch=item.batch,
|
batch=item.batch,
|
||||||
defaults={"count": 0}
|
defaults={"count": 0, "production_dept": production_dept}
|
||||||
)
|
)
|
||||||
if not is_created:
|
if not is_created:
|
||||||
raise ParseError("该批次组合件已存在")
|
raise ParseError("该批次组合件已存在")
|
||||||
|
|
Loading…
Reference in New Issue