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()
|
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,
|
wm, new_create = WMaterial.objects.get_or_create(batch=xbatch, material=xmaterial,
|
||||||
belong_dept=belong_dept, mgroup=mgroup,
|
belong_dept=belong_dept, mgroup=mgroup,
|
||||||
state=WMaterial.WM_OK,
|
state=WMaterial.WM_OK)
|
||||||
defaults=ddict)
|
if new_create:
|
||||||
if not new_create:
|
wm.create_by = do_user
|
||||||
wm.count = wm.count + item.count
|
wm.batch_ofrom = mb.batch if mb else None
|
||||||
wm.update_by = do_user
|
wm.material_ofrom = mb.material if mb else None
|
||||||
wm.batch_ofrom = mb.batch_ofrom if mb else None
|
wm.count = wm.count + item.count
|
||||||
wm.material_ofrom = mb.material_ofrom if mb else None
|
wm.update_by = do_user
|
||||||
wm.save()
|
wm.save()
|
||||||
|
|
||||||
|
|
||||||
def do_in(item: MIOItem):
|
def do_in(item: MIOItem):
|
||||||
|
@ -154,7 +145,7 @@ def do_in(item: MIOItem):
|
||||||
defaults={
|
defaults={
|
||||||
"count": 0,
|
"count": 0,
|
||||||
"batch_ofrom": wm.batch_ofrom,
|
"batch_ofrom": wm.batch_ofrom,
|
||||||
"material_ofrom": xmaterial,
|
"material_ofrom": wm.material_ofrom,
|
||||||
"production_dept": production_dept
|
"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():
|
for mi in m_ins.all():
|
||||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||||
if mi.count_pn_jgqbl > 0:
|
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:
|
else:
|
||||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||||
for mi in m_ins_list:
|
for mi in m_ins_list:
|
||||||
|
@ -170,15 +170,16 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
wm.save()
|
wm.save()
|
||||||
# 针对加工前不良的暂时额外处理
|
# 针对加工前不良的暂时额外处理
|
||||||
for item in m_ins_bl_list:
|
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:
|
if count_pn_jgqbl> 0:
|
||||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
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, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||||
wm.count = wm.count + count_pn_jgqbl
|
wm.count = wm.count + count_pn_jgqbl
|
||||||
if is_create:
|
if is_create:
|
||||||
wm.create_by = user
|
wm.create_by = user
|
||||||
else:
|
wm.batch_ofrom = mi_.batch_ofrom
|
||||||
wm.update_by = user
|
wm.material_ofrom = mi_.material_ofrom
|
||||||
|
wm.update_by = user
|
||||||
wm.save()
|
wm.save()
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,6 +219,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if supplier is not None:
|
if supplier is not None:
|
||||||
wm.supplier = supplier
|
wm.supplier = supplier
|
||||||
if is_create2:
|
if is_create2:
|
||||||
|
wm.create_by = user
|
||||||
if isinstance(mlog_or_b, Mlog) and mlog_or_b.wm_in:
|
if isinstance(mlog_or_b, Mlog) and mlog_or_b.wm_in:
|
||||||
wm.batch_ofrom = mlog_or_b.wm_in.batch_ofrom
|
wm.batch_ofrom = mlog_or_b.wm_in.batch_ofrom
|
||||||
wm.material_ofrom = mlog_or_b.wm_in.material_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,
|
state=WMaterial.WM_OK,
|
||||||
defaults={
|
defaults={
|
||||||
"batch_ofrom": wm_from.batch_ofrom,
|
"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:
|
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,
|
state=WMaterial.WM_REPAIR,
|
||||||
defaults={
|
defaults={
|
||||||
"batch_ofrom": wm_from.batch_ofrom,
|
"batch_ofrom": wm_from.batch_ofrom,
|
||||||
"material_ofrom": wm_from.material_ofrom
|
"material_ofrom": wm_from.material_ofrom,
|
||||||
|
"create_by": user
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -542,7 +546,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
||||||
defaults={
|
defaults={
|
||||||
"count_xtest": 0,
|
"count_xtest": 0,
|
||||||
"batch_ofrom": wm_from.batch_ofrom,
|
"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:
|
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,
|
state=WMaterial.WM_SCRAP,
|
||||||
defaults={
|
defaults={
|
||||||
"batch_ofrom": wm_from.batch_ofrom,
|
"batch_ofrom": wm_from.batch_ofrom,
|
||||||
"material_ofrom": wm_from.material_ofrom
|
"material_ofrom": wm_from.material_ofrom,
|
||||||
|
"create_by": user
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue