fix: ftestwork validate bug

This commit is contained in:
caoqianming 2025-03-04 09:07:30 +08:00
parent 46d586430e
commit 71cbda504c
1 changed files with 4 additions and 1 deletions

View File

@ -155,6 +155,7 @@ class FtestWorkCreateUpdateSerializer(CustomModelSerializer):
def validate(self, attrs): def validate(self, attrs):
qct = attrs.get("qct", None) qct = attrs.get("qct", None)
ftestworkdefect = attrs.get("ftestworkdefect", [])
type2 = attrs.get('type2', 20) type2 = attrs.get('type2', 20)
if type2 == 20: # 如果是全检 if type2 == 20: # 如果是全检
attrs['count_sampling'] = attrs['count'] attrs['count_sampling'] = attrs['count']
@ -168,7 +169,9 @@ class FtestWorkCreateUpdateSerializer(CustomModelSerializer):
attrs['material'] = wm.material attrs['material'] = wm.material
attrs['batch'] = wm.batch attrs['batch'] = wm.batch
count_notok_json = attrs.get('count_notok_json', None) count_notok_json = attrs.get('count_notok_json', None)
if qct is None: # 没有qct时按原有逻辑处理 if qct or ftestworkdefect: # 没有qct时按原有逻辑处理
pass
else:
if count_notok_json is None: if count_notok_json is None:
raise ValidationError('不合格项不能为空') raise ValidationError('不合格项不能为空')
count_notok = 0 count_notok = 0