fix: do_out 领料时的material_ofrom
This commit is contained in:
parent
6ef01ee301
commit
4518344fa6
|
@ -68,25 +68,16 @@ def do_out(item: MIOItem):
|
|||
mb.save()
|
||||
|
||||
# 领到车间库存(或工段)
|
||||
ddict = {
|
||||
"batch": xbatch,
|
||||
"material": xmaterial,
|
||||
"count": xcount,
|
||||
"create_by": do_user,
|
||||
"belong_dept": belong_dept,
|
||||
"mgroup": mgroup,
|
||||
"state": WMaterial.WM_OK,
|
||||
}
|
||||
wm, new_create = WMaterial.objects.get_or_create(batch=xbatch, material=xmaterial,
|
||||
belong_dept=belong_dept, mgroup=mgroup,
|
||||
state=WMaterial.WM_OK,
|
||||
defaults=ddict)
|
||||
if not new_create:
|
||||
wm.count = wm.count + item.count
|
||||
wm.update_by = do_user
|
||||
wm.batch_ofrom = mb.batch_ofrom if mb else None
|
||||
wm.material_ofrom = mb.material_ofrom if mb else None
|
||||
wm.save()
|
||||
state=WMaterial.WM_OK)
|
||||
if new_create:
|
||||
wm.create_by = do_user
|
||||
wm.batch_ofrom = mb.batch if mb else None
|
||||
wm.material_ofrom = mb.material if mb else None
|
||||
wm.count = wm.count + item.count
|
||||
wm.update_by = do_user
|
||||
wm.save()
|
||||
|
||||
|
||||
def do_in(item: MIOItem):
|
||||
|
@ -154,7 +145,7 @@ def do_in(item: MIOItem):
|
|||
defaults={
|
||||
"count": 0,
|
||||
"batch_ofrom": wm.batch_ofrom,
|
||||
"material_ofrom": xmaterial,
|
||||
"material_ofrom": wm.material_ofrom,
|
||||
"production_dept": production_dept
|
||||
}
|
||||
)
|
||||
|
|
|
@ -137,7 +137,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
for mi in m_ins.all():
|
||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||
if mi.count_pn_jgqbl > 0:
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl))
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl, mi))
|
||||
else:
|
||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||
for mi in m_ins_list:
|
||||
|
@ -170,15 +170,16 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
wm.save()
|
||||
# 针对加工前不良的暂时额外处理
|
||||
for item in m_ins_bl_list:
|
||||
material, batch, count_pn_jgqbl = item
|
||||
material, batch, count_pn_jgqbl, mi_ = item
|
||||
if count_pn_jgqbl> 0:
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||
wm.count = wm.count + count_pn_jgqbl
|
||||
if is_create:
|
||||
wm.create_by = user
|
||||
else:
|
||||
wm.update_by = user
|
||||
wm.batch_ofrom = mi_.batch_ofrom
|
||||
wm.material_ofrom = mi_.material_ofrom
|
||||
wm.update_by = user
|
||||
wm.save()
|
||||
|
||||
|
||||
|
@ -218,6 +219,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
if supplier is not None:
|
||||
wm.supplier = supplier
|
||||
if is_create2:
|
||||
wm.create_by = user
|
||||
if isinstance(mlog_or_b, Mlog) and mlog_or_b.wm_in:
|
||||
wm.batch_ofrom = mlog_or_b.wm_in.batch_ofrom
|
||||
wm.material_ofrom = mlog_or_b.wm_in.material_ofrom
|
||||
|
@ -512,7 +514,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
state=WMaterial.WM_OK,
|
||||
defaults={
|
||||
"batch_ofrom": wm_from.batch_ofrom,
|
||||
"material_ofrom": wm_from.material_ofrom
|
||||
"material_ofrom": wm_from.material_ofrom,
|
||||
"create_by": user
|
||||
}
|
||||
)
|
||||
elif handover.type == Handover.H_REPAIR:
|
||||
|
@ -527,7 +530,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
state=WMaterial.WM_REPAIR,
|
||||
defaults={
|
||||
"batch_ofrom": wm_from.batch_ofrom,
|
||||
"material_ofrom": wm_from.material_ofrom
|
||||
"material_ofrom": wm_from.material_ofrom,
|
||||
"create_by": user
|
||||
}
|
||||
)
|
||||
else:
|
||||
|
@ -542,7 +546,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
defaults={
|
||||
"count_xtest": 0,
|
||||
"batch_ofrom": wm_from.batch_ofrom,
|
||||
"material_ofrom": wm_from.material_ofrom
|
||||
"material_ofrom": wm_from.material_ofrom,
|
||||
"create_by": user
|
||||
},
|
||||
)
|
||||
elif handover.type == Handover.H_SCRAP:
|
||||
|
@ -556,7 +561,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
state=WMaterial.WM_SCRAP,
|
||||
defaults={
|
||||
"batch_ofrom": wm_from.batch_ofrom,
|
||||
"material_ofrom": wm_from.material_ofrom
|
||||
"material_ofrom": wm_from.material_ofrom,
|
||||
"create_by": user
|
||||
}
|
||||
)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue