diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index dc209f6b..ddb134cb 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -628,21 +628,20 @@ class MlogInitSerializer(CustomModelSerializer): } def validate(self, attrs): - route: Route = attrs.get('route', None) mgroup: Mgroup = attrs['mgroup'] is_fix:bool = attrs.get('is_fix', False) attrs['mtype'] = mgroup.mtype if is_fix: attrs["route"] = None - elif route is None: - raise ParseError('缺少工艺路线') - if route and route.process != mgroup.process: - raise ParseError('工序不匹配') - if is_fix: attrs['hour_work'] = None attrs['material_in'] = None attrs['material_out'] = None - if route: + else: + route: Route = attrs.get('route', None) + if not route: + raise ParseError('缺少工艺路线') + if route and route.process != mgroup.process: + raise ParseError('工序不匹配') attrs['hour_work'] = route.hour_work attrs['material_in'] = route.material_in attrs['material_out'] = route.material_out