diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 7605c18f..72698c8d 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -498,8 +498,10 @@ class MlogInitSerializer(CustomModelSerializer): mtype = attrs['mtype'] route: Route = attrs['route'] mgroup: Mgroup = attrs['mgroup'] + if route is None: + raise ParseError('缺少工艺路线') if route.process != mgroup.process: - raise ValidationError('工序不匹配') + raise ParseError('工序不匹配') attrs['hour_work'] = route.hour_work attrs['material_in'] = route.material_in attrs['material_out'] = route.material_out @@ -507,7 +509,7 @@ class MlogInitSerializer(CustomModelSerializer): if mtype == Mlog.MTYPE_OUT: supplier = attrs.get('supplier', None) if not supplier: - raise ValidationError('外协必须选择外协单位') + raise ParseError('外协必须选择外协单位') if attrs.get('work_end_time', None): attrs['handle_date'] = localdate(attrs['work_end_time']) return attrs