fix: handover serializer bug2

This commit is contained in:
caoqianming 2024-07-02 23:25:14 +08:00
parent 67ca07bb35
commit 59b8634d3e
1 changed files with 3 additions and 3 deletions

View File

@ -345,8 +345,8 @@ class HandoverSerializer(CustomModelSerializer):
attrs['send_dept'] = attrs['wm'].belong_dept
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 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:
@ -356,7 +356,7 @@ class HandoverSerializer(CustomModelSerializer):
class Meta:
model = Handover
fields = '__all__'
read_only_fields = EXCLUDE_FIELDS + ["batch", "material", "send_dept", "mlog"]
read_only_fields = EXCLUDE_FIELDS + ["mlog"]
extra_kwargs = {
"wm": {"required": True},
"recive_mgroup": {"required": False}