From a6a3dcf33c3c8c2419d8296a508990b31077993a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 1 Jul 2024 16:21:52 +0800 Subject: [PATCH] fix: handover validate bug --- apps/wpm/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index de67c9a4..2093970a 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -338,12 +338,13 @@ class HandoverSerializer(CustomModelSerializer): source='material', read_only=True) def validate(self, attrs): - material: Material = attrs['material'] - if material.process.into_wm_mgroup and 'recive_mgroup' not in attrs: - raise ValidationError('必须指定交接工段') if attrs.get('wm', None): + material = attrs['wm'].material + attrs['material'] = attrs['wm'].material attrs['send_dept'] = attrs['wm'].belong_dept attrs['send_mgroup'] = attrs['wm'].mgroup + if material.process and material.process.into_wm_mgroup and 'recive_mgroup' not in attrs: + raise ValidationError('必须指定交接工段') if attrs.get('recive_mgroup', None): attrs['recive_dept'] = attrs['recive_mgroup'].belong_dept if 'recive_dept' not in attrs and 'recive_mgroup' not in attrs: