diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index a468824b..f84ee9fa 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -624,12 +624,14 @@ class HandoverSerializer(CustomModelSerializer): attrs['batch'] = wm.batch elif handoverb: wm: WMaterial = handoverb[0]["wm"] + if wm: + pass else: raise ParseError('必须指定车间库存') attrs['material'] = wm.material attrs['send_dept'] = wm.belong_dept - if handoverb[0]["wm"].mgroup: - attrs['send_mgroup'] = handoverb[0]["wm"].mgroup + if wm.mgroup: + attrs['send_mgroup'] = wm.mgroup if attrs['material'].process and attrs['material'].process.into_wm_mgroup and 'recive_mgroup' not in attrs: raise ValidationError('必须指定交接工段') if 'recive_mgroup' in attrs and attrs['recive_mgroup']: @@ -642,6 +644,8 @@ class HandoverSerializer(CustomModelSerializer): for ind, item in enumerate(attrs['handoverb']): wm = item["wm"] t_count += item["count"] + if wm.mgroup != attrs['send_mgroup']: + raise ParseError(f'第{ind+1}物料与交接工段不一致') if attrs["material"] != wm.material: raise ParseError(f'第{ind+1}物料与交接物料不一致') if wm.notok_sign is not None and attrs['type'] in [Handover.H_NORMAL, Handover.H_TEST]: