fix: need_inout 传true时也得处理

This commit is contained in:
caoqianming 2025-05-15 14:49:40 +08:00
parent ca9d46c8d5
commit cbeecea2dc
1 changed files with 6 additions and 1 deletions

View File

@ -878,13 +878,18 @@ class MlogbOutUpdateSerializer(CustomModelSerializer):
if ins.need_inout is False:
if ins.mlogb_from:
if Mlogb.objects.filter(mlog=ins.mlog, material_out__isnull=False, mlogb_from=ins.mlogb_from).count() == 1:
ins_from =Mlogb.objects.filter(mlog=ins.mlog, material_out__isnull=False, mlogb_from=ins.mlogb_from).first()
ins_from = ins.mlogb_from
ins_from.need_inout = False
ins_from.save(update_fields=["need_inout"])
else:
raise ParseError("对应消耗的产出有多个, 需手动指定消耗是否出库")
else:
raise ParseError("该产出需入库!")
else:
if ins.mlogb_from:
ins_from = ins.mlogb_from
ins_from.need_inout = True
ins_from.save(update_fields=["need_inout"])
if mlogbdefect is not None and ins.material_out.tracking == Material.MA_TRACKING_BATCH:
MlogbDefect.objects.filter(mlogb=ins).delete()
mlogb_defect_objects = [