diff --git a/apps/qm/services.py b/apps/qm/services.py index 299d9abb..715abae8 100644 --- a/apps/qm/services.py +++ b/apps/qm/services.py @@ -100,10 +100,10 @@ def ftestwork_submit(ins:FtestWork, user: User): for item in FtestworkDefect.objects.filter(ftestwork=ins): item:FtestworkDefect = item if item.count > 0 and item.defect.okcate == Defect.DEFECT_NOTOK: - ins.count = ins.count - item.count - if ins.count < 0: + wm.count = wm.count - item.count + if wm.count < 0: raise ParseError("数量不足,扣减失败") - wm, new_create = WMaterial.objects.get_or_create( + wmx, new_create = WMaterial.objects.get_or_create( material=wm.material, batch=wm.batch, mgroup=wm.mgroup, @@ -116,10 +116,9 @@ def ftestwork_submit(ins:FtestWork, user: User): } ) if not new_create: - wm.count = wm.count + item.count - wm.save() + wmx.count = wmx.count + item.count + wmx.save() ins.save() - wm.count = wm.count - ins.count_notok wm.save() ins.submit_user = user ins.submit_time = timezone.now()