From f9bd8a3607a234ad577e556445316ab4f298c759 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 13 Jan 2025 18:04:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ftestwork=20submit=20wm=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=89=A3=E5=87=8Fbug2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/qm/services.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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()