From f51bb48428614031c4ea63040cdcd2d7dedc2601 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 13 Sep 2024 12:53:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20handover=20serializer=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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]: