fix: mlogbw删除的bug
This commit is contained in:
parent
868b37559f
commit
6fbe0a7b1c
|
@ -201,6 +201,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if mlogbws.count() != mi_count:
|
if mlogbws.count() != mi_count:
|
||||||
raise ParseError("日志与明细数量不一致,操作失败")
|
raise ParseError("日志与明细数量不一致,操作失败")
|
||||||
for item in mlogbws:
|
for item in mlogbws:
|
||||||
|
if item.test:
|
||||||
|
raise ParseError("不支持消耗物料的检验")
|
||||||
Wpr.change_or_new(wpr=item.wpr, old_wm=wm)
|
Wpr.change_or_new(wpr=item.wpr, old_wm=wm)
|
||||||
|
|
||||||
# 针对加工前不良的暂时额外处理
|
# 针对加工前不良的暂时额外处理
|
||||||
|
|
|
@ -607,8 +607,8 @@ class MlogbwViewSet(CustomModelViewSet):
|
||||||
mlogb.count_use = count
|
mlogb.count_use = count
|
||||||
elif mlogb.material_out:
|
elif mlogb.material_out:
|
||||||
mlogb.count_real = count
|
mlogb.count_real = count
|
||||||
mlogb.count_ok = count
|
mlogb.count_notok = Mlogbw.objects.filter(mlogb=mlogb, ftest__is_ok=False).count()
|
||||||
mlogb.count_notok = 0
|
mlogb.count_ok = count - mlogb.count_notok
|
||||||
mlogb.save()
|
mlogb.save()
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -628,13 +628,15 @@ class MlogbwViewSet(CustomModelViewSet):
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_update(self, serializer):
|
def perform_update(self, serializer):
|
||||||
mlogbw = serializer.save()
|
mlogbw = serializer.save()
|
||||||
|
self.cal_mlogb_count(mlogbw.mlogb)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_destroy(self, instance:Mlogbw):
|
def perform_destroy(self, instance:Mlogbw):
|
||||||
mlogb = instance.mlogb
|
mlogb = instance.mlogb
|
||||||
if instance.ftest:
|
ftest = instance.ftest
|
||||||
instance.ftest.delete()
|
|
||||||
instance.delete()
|
instance.delete()
|
||||||
|
if ftest:
|
||||||
|
ftest.delete()
|
||||||
self.cal_mlogb_count(mlogb)
|
self.cal_mlogb_count(mlogb)
|
||||||
# 如果是输入且输出追踪到个,需同步删除
|
# 如果是输入且输出追踪到个,需同步删除
|
||||||
material_in: Material = mlogb.material_in
|
material_in: Material = mlogb.material_in
|
||||||
|
|
Loading…
Reference in New Issue