fix:锁定 MIO 行,防止多人同时撤销不同明细时并发漏删 MIO,若该出入库记录已无明细,自动删除
This commit is contained in:
parent
b108b48714
commit
0dd78f09b9
|
|
@ -463,7 +463,8 @@ class InmService:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def revert_and_del(cls, mioitem: MIOItem):
|
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:
|
if mio.submit_time is None:
|
||||||
raise ParseError("未提交的出入库明细不允许撤销")
|
raise ParseError("未提交的出入库明细不允许撤销")
|
||||||
if mioitem.test_date is not None:
|
if mioitem.test_date is not None:
|
||||||
|
|
@ -484,4 +485,7 @@ class InmService:
|
||||||
mioitem.delete()
|
mioitem.delete()
|
||||||
else:
|
else:
|
||||||
raise ParseError("不支持该出入库单明细撤销")
|
raise ParseError("不支持该出入库单明细撤销")
|
||||||
|
# 若该出入库记录已无明细,自动删除
|
||||||
|
if not MIOItem.objects.filter(mio=mio).exists():
|
||||||
|
mio.delete()
|
||||||
|
|
||||||
Loading…
Reference in New Issue