From 6033216869a444eb296a5bb00f9a8155f423e815 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Apr 2025 14:21:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mloginit=E5=9C=A8=E8=BF=94=E5=B7=A5?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E6=8E=A5=E6=94=B6route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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