diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 1045945e..28311394 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -983,10 +983,10 @@ class HandoverSerializer(CustomModelSerializer): raise ParseError('必须指定交接工段') if 'recive_mgroup' in attrs and attrs['recive_mgroup']: attrs['recive_dept'] = attrs['recive_mgroup'].belong_dept - if 'recive_dept' not in attrs and 'recive_mgroup' not in attrs: - raise ParseError('收料车间和收料工段必须有一个') - if 'send_dept' not in attrs and 'send_mgroup' not in attrs: - raise ParseError('送料车间和送料工段必须有一个') + if not attrs.get('recive_dept', None) and not attrs.get('recive_mgroup', None): + raise ParseError('必须指定收料车间或收料工段') + if not attrs.get('send_dept', None) and not attrs.get('send_mgroup', None): + raise ParseError('必须指定送料车间或送料工段') t_count = 0 tracking = attrs["material"].tracking for ind, item in enumerate(attrs['handoverb']): @@ -1186,7 +1186,7 @@ class FmlogSerializer(CustomModelSerializer): is_fix = attrs.get("is_fix", False) if is_fix: attrs["mtask"] = None - elif not attrs.get("mtask", None) or not attrs.get("route", None): + elif not attrs.get("mtask", None) and not attrs.get("route", None): raise ParseError("请选择任务或工艺步骤") mtask: Mtask = attrs['mtask'] if mtask and mtask.state != Mtask.MTASK_ASSGINED: