diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 2093970a..a1e913f0 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -341,8 +341,10 @@ class HandoverSerializer(CustomModelSerializer): if attrs.get('wm', None): material = attrs['wm'].material attrs['material'] = attrs['wm'].material + attrs['batch'] = attrs['wm'].batch attrs['send_dept'] = attrs['wm'].belong_dept - attrs['send_mgroup'] = attrs['wm'].mgroup + if attrs['wm'].mgroup: + 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): @@ -354,7 +356,7 @@ class HandoverSerializer(CustomModelSerializer): class Meta: model = Handover fields = '__all__' - read_only_fields = EXCLUDE_FIELDS + ["batch", "material", "send_dept", "send_mgroup", "mlog"] + read_only_fields = EXCLUDE_FIELDS + ["batch", "material", "send_dept", "mlog"] extra_kwargs = { "wm": {"required": True}, "recive_mgroup": {"required": False}