fix: handover validate bug

This commit is contained in:
caoqianming 2024-07-01 16:21:52 +08:00
parent d579a7358d
commit a6a3dcf33c
1 changed files with 4 additions and 3 deletions

View File

@ -338,12 +338,13 @@ class HandoverSerializer(CustomModelSerializer):
source='material', read_only=True) source='material', read_only=True)
def validate(self, attrs): 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): if attrs.get('wm', None):
material = attrs['wm'].material
attrs['material'] = attrs['wm'].material
attrs['send_dept'] = attrs['wm'].belong_dept attrs['send_dept'] = attrs['wm'].belong_dept
attrs['send_mgroup'] = 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): if attrs.get('recive_mgroup', None):
attrs['recive_dept'] = attrs['recive_mgroup'].belong_dept attrs['recive_dept'] = attrs['recive_mgroup'].belong_dept
if 'recive_dept' not in attrs and 'recive_mgroup' not in attrs: if 'recive_dept' not in attrs and 'recive_mgroup' not in attrs: