fix: mlogdefect 空列表时仍同步继承缺陷
前端传 mlogdefect: [] 时,原 is not None 判断会走进 need_mdfect 分支, 既不创建真实缺陷也跳过 sync_inherited_defect,导致 mlogb 无任何缺陷标识。 改为无论哪个分支都兜底调用 sync_inherited_defect,由其内部判断互斥。
This commit is contained in:
parent
c2ee88d2bf
commit
e2b1f266aa
|
|
@ -478,8 +478,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
if mlogb_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogb_defect_objects)
|
||||
mlogb.cal_count_notok(cal_mlog=False)
|
||||
else:
|
||||
mlogb.sync_inherited_defect(cal_count=True)
|
||||
mlogb.sync_inherited_defect(cal_count=True)
|
||||
instance.cal_mlog_count_from_mlogb()
|
||||
return instance
|
||||
|
||||
|
|
@ -570,7 +569,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
mox.save()
|
||||
Mlogb.objects.filter(mlog=instance, material_out__isnull=False).exclude(id=mox.id).delete()
|
||||
if need_mdefect:
|
||||
MlogbDefect.objects.filter(mlogb__mlog=instance).delete()
|
||||
MlogbDefect.objects.filter(mlogb__mlog=instance, is_inherited=False).delete()
|
||||
mlogb_defect_objects = [
|
||||
MlogbDefect(**{**item, "mlogb": mox, "id": idWorker.get_id()})
|
||||
for item in mlogdefect if item["count"] > 0
|
||||
|
|
@ -578,8 +577,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
if mlogb_defect_objects:
|
||||
MlogbDefect.objects.bulk_create(mlogb_defect_objects)
|
||||
mox.cal_count_notok(cal_mlog=False)
|
||||
else:
|
||||
mox.sync_inherited_defect(cal_count=True)
|
||||
mox.sync_inherited_defect(cal_count=True)
|
||||
instance.cal_mlog_count_from_mlogb()
|
||||
return instance
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue