fix: 交接分批bug/加工前不良的bug
This commit is contained in:
parent
e0217e86c4
commit
300023ff81
|
@ -373,7 +373,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
if mlogbindefect is not None:
|
||||
mlogbin_defect_objects = [
|
||||
MlogbDefect(**{**item, "mlogb": mlogbin, "id": idWorker.get_id()})
|
||||
for item in mlogdefect if item["count"] > 0
|
||||
for item in mlogbindefect if item["count"] > 0
|
||||
]
|
||||
if mlogbin_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogbin_defect_objects)
|
||||
|
@ -476,7 +476,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
if mlogbindefect is not None:
|
||||
mlogbin_defect_objects = [
|
||||
MlogbDefect(**{**item, "mlogb": minx, "id": idWorker.get_id()})
|
||||
for item in mlogdefect if item["count"] > 0
|
||||
for item in mlogbindefect if item["count"] > 0
|
||||
]
|
||||
if mlogbin_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogbin_defect_objects)
|
||||
|
@ -1062,8 +1062,8 @@ class HandoverSerializer(CustomModelSerializer):
|
|||
if mtype == Handover.H_DIV:
|
||||
if not item["batch"]:
|
||||
raise ParseError(f'第{ind+1}行-请提供拆批批次号')
|
||||
if wm is not None:
|
||||
raise ParseError("拆批错误")
|
||||
if ins.wm is None:
|
||||
raise ParseError("请提供拆批库存")
|
||||
handoverb = Handoverb.objects.create(handover=ins, batch=item["batch"], count=count, wm=ins.wm)
|
||||
else:
|
||||
handoverb = Handoverb.objects.create(handover=ins, wm=wm, count=count, batch=wm.batch)
|
||||
|
@ -1084,7 +1084,7 @@ class HandoverSerializer(CustomModelSerializer):
|
|||
def update(self, instance, validated_data):
|
||||
handoverb = validated_data.pop('handoverb', [])
|
||||
with transaction.atomic():
|
||||
super().update(instance, validated_data)
|
||||
insx = super().update(instance, validated_data)
|
||||
Handoverb.objects.filter(handover=instance).delete()
|
||||
for ind, item in enumerate(handoverb):
|
||||
wm = item["wm"]
|
||||
|
@ -1093,7 +1093,9 @@ class HandoverSerializer(CustomModelSerializer):
|
|||
if validated_data["mtype"] == Handover.H_DIV:
|
||||
if not item["batch"]:
|
||||
raise ParseError(f'第{ind+1}行-请提供拆批批次号')
|
||||
hb, _ = Handoverb.objects.get_or_create(handover=instance, batch=item["batch"], wm=wm,
|
||||
if insx.wm is None:
|
||||
raise ParseError("请提供拆批库存")
|
||||
hb, _ = Handoverb.objects.get_or_create(handover=instance, batch=item["batch"], wm=insx.wm,
|
||||
defaults={"count": count})
|
||||
else:
|
||||
hb, _ = Handoverb.objects.get_or_create(handover=instance, wm=wm, defaults={"count": count,
|
||||
|
|
|
@ -701,9 +701,9 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
if '混料' in material.name: # hard code
|
||||
need_add = False
|
||||
if handoverb_qs.exists():
|
||||
handoverb_list = [(item.wm, item.count, item) for item in handoverb_qs]
|
||||
handoverb_list = [(item.wm.id, item.count, item) for item in handoverb_qs]
|
||||
else:
|
||||
handoverb_list = [(handover.wm, handover.count, handover)]
|
||||
handoverb_list = [(handover.wm.id, handover.count, handover)]
|
||||
|
||||
recive_mgroup = handover.recive_mgroup
|
||||
recive_dept = handover.recive_dept
|
||||
|
@ -717,7 +717,8 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
|
||||
new_target = None
|
||||
for item in handoverb_list:
|
||||
wm_from, xcount, handover_or_b = item
|
||||
wmId, xcount, handover_or_b = item
|
||||
wm_from = WMaterial.objects.get(id=wmId)
|
||||
|
||||
# 合并为新批
|
||||
if mtype == Handover.H_MERGE:
|
||||
|
@ -731,7 +732,6 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
if handover.wm is None:
|
||||
raise ParseError('拆批请选择车间库存')
|
||||
wm_from = handover.wm
|
||||
source, _ = BatchSt.g_create(batch=handover.wm.batch)
|
||||
BatchLog.g_create(source=source, target=target, handover=handover, relation_type="split")
|
||||
else:
|
||||
|
@ -741,13 +741,14 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
if wm_from is None:
|
||||
raise ParseError('找不到车间库存')
|
||||
|
||||
|
||||
print(wm_from.count)
|
||||
count_x = wm_from.count - xcount
|
||||
if count_x < 0:
|
||||
raise ParseError('车间库存不足!')
|
||||
else:
|
||||
wm_from.count = count_x
|
||||
wm_from.save()
|
||||
print(wm_from.count)
|
||||
|
||||
if need_add:
|
||||
# 开始变动
|
||||
|
|
Loading…
Reference in New Issue