fix: handover serializer bug

This commit is contained in:
caoqianming 2024-07-02 23:04:16 +08:00
parent bad338ba67
commit 67ca07bb35
1 changed files with 4 additions and 2 deletions

View File

@ -341,8 +341,10 @@ class HandoverSerializer(CustomModelSerializer):
if attrs.get('wm', None): if attrs.get('wm', None):
material = attrs['wm'].material material = attrs['wm'].material
attrs['material'] = attrs['wm'].material attrs['material'] = attrs['wm'].material
attrs['batch'] = attrs['wm'].batch
attrs['send_dept'] = attrs['wm'].belong_dept 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: if material.process and material.process.into_wm_mgroup and 'recive_mgroup' not in attrs:
raise ValidationError('必须指定交接工段') raise ValidationError('必须指定交接工段')
if attrs.get('recive_mgroup', None): if attrs.get('recive_mgroup', None):
@ -354,7 +356,7 @@ class HandoverSerializer(CustomModelSerializer):
class Meta: class Meta:
model = Handover model = Handover
fields = '__all__' 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 = { extra_kwargs = {
"wm": {"required": True}, "wm": {"required": True},
"recive_mgroup": {"required": False} "recive_mgroup": {"required": False}