feat: 尝试从个号追踪到历史记录的个号2

This commit is contained in:
caoqianming 2025-04-28 14:12:00 +08:00
parent 25a111bc6b
commit c5a7a19f74
2 changed files with 14 additions and 8 deletions

View File

@ -802,7 +802,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
"create_by": user,
"number_from": wm_from.number_from
}
)
elif handover.type == Handover.H_REPAIR:
@ -825,7 +826,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
"create_by": user,
"number_from": wm_from.number_from
}
)
else:
@ -857,7 +859,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
"create_by": user,
"number_from": wm_from.number_from
}
)
else:
@ -876,7 +879,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
"create_by": user,
"number_from": wm_from.number_from
}
)
else:
@ -896,7 +900,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
"create_by": user,
"number_from": wm_from.number_from
}
)
else:

View File

@ -617,14 +617,15 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
if Mlogbw.objects.filter(mlogb=mlogbin).count() == 1:
mlogbwin = Mlogbw.objects.filter(mlogb=mlogbin).first()
mlogbout, _ = Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": div_number, "count_ok": div_number}))
mlogbout.count_json_from = mlogbin.count_json_from
mlogbout.number_from = mlogbwin.number
mlogbout.save(update_fields=["count_json_from"])
mlogbout.save(update_fields=["number_from"])
else:
# 用个号做批号是用于后续在复用个号可以追踪到原先的个
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
m_dict["batch"] = mlogbwin.number
Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, defaults=update_dict(m_dict, {"count_real": div_number, "count_ok": div_number}))
mlogbout, _ = Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, defaults=update_dict(m_dict, {"count_real": div_number, "count_ok": div_number}))
mlogbout.number_from = mlogbwin.number
mlogbout.save(update_fields=["number_from"])
elif material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
d_count_real = mlogbin.count_use * div_number
d_count_ok = d_count_real