From 0dd78f09b9e3e03e8eed204dc9cddd28f9cf6551 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 22 May 2026 09:43:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=94=81=E5=AE=9A=20MIO=20=E8=A1=8C?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=A4=9A=E4=BA=BA=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=92=A4=E9=94=80=E4=B8=8D=E5=90=8C=E6=98=8E=E7=BB=86=E6=97=B6?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E6=BC=8F=E5=88=A0=20MIO,=E8=8B=A5=E8=AF=A5?= =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=E5=B7=B2=E6=97=A0?= =?UTF-8?q?=E6=98=8E=E7=BB=86=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/services.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/inm/services.py b/apps/inm/services.py index 8de7c4bf..6fb4203c 100644 --- a/apps/inm/services.py +++ b/apps/inm/services.py @@ -463,7 +463,8 @@ class InmService: @classmethod def revert_and_del(cls, mioitem: MIOItem): - mio = mioitem.mio + # 锁定 MIO 行,防止多人同时撤销不同明细时并发漏删 MIO + mio = MIO.objects.select_for_update().get(id=mioitem.mio_id) if mio.submit_time is None: raise ParseError("未提交的出入库明细不允许撤销") if mioitem.test_date is not None: @@ -484,4 +485,7 @@ class InmService: mioitem.delete() else: raise ParseError("不支持该出入库单明细撤销") + # 若该出入库记录已无明细,自动删除 + if not MIOItem.objects.filter(mio=mio).exists(): + mio.delete() \ No newline at end of file