feat: handover count可不填写

This commit is contained in:
caoqianming 2024-09-05 12:50:51 +08:00
parent e2f4cd1612
commit 0baec25a8b
1 changed files with 5 additions and 0 deletions

View File

@ -593,14 +593,17 @@ class HandoverSerializer(CustomModelSerializer):
raise ValidationError('收料车间和收料工段必须有一个') raise ValidationError('收料车间和收料工段必须有一个')
if 'send_dept' not in attrs and 'send_mgroup' not in attrs: if 'send_dept' not in attrs and 'send_mgroup' not in attrs:
raise ValidationError('送料车间和送料工段必须有一个') raise ValidationError('送料车间和送料工段必须有一个')
t_count = 0
for ind, item in enumerate(handoverb): for ind, item in enumerate(handoverb):
wm = item["wm"] wm = item["wm"]
t_count += item["count"]
if attrs["material"] != wm.material: if attrs["material"] != wm.material:
raise ParseError(f'{ind+1}物料与交接物料不一致') raise ParseError(f'{ind+1}物料与交接物料不一致')
if wm.notok_sign is not None and attrs['type'] in [Handover.H_NORMAL, Handover.H_TEST]: if wm.notok_sign is not None and attrs['type'] in [Handover.H_NORMAL, Handover.H_TEST]:
raise ParseError(f'{ind+1}物料不合格,不能进行正常/检验交接') raise ParseError(f'{ind+1}物料不合格,不能进行正常/检验交接')
if wm.count_xtest is not None: if wm.count_xtest is not None:
raise ParseError(f'{ind+1}物料检验中,不能进行交接') raise ParseError(f'{ind+1}物料检验中,不能进行交接')
attrs["count"] = t_count
if attrs['type'] == Handover.H_SCRAP: if attrs['type'] == Handover.H_SCRAP:
attrs['recive_mgroup'] = attrs['send_mgroup'] attrs['recive_mgroup'] = attrs['send_mgroup']
attrs['recive_dept'] = attrs['send_dept'] attrs['recive_dept'] = attrs['send_dept']
@ -619,6 +622,8 @@ class HandoverSerializer(CustomModelSerializer):
"recive_dept": {"required": False}, "recive_dept": {"required": False},
"material": {"required": False}, "material": {"required": False},
"batch": {"required": False}, "batch": {"required": False},
"count": {"required": False},
"count_eweight": {"required": False}
} }
def create(self, validated_data): def create(self, validated_data):