fix: mloginit在返工时不接收route

This commit is contained in:
caoqianming 2025-04-25 14:21:24 +08:00
parent 000ea6fc27
commit 6033216869
1 changed files with 6 additions and 7 deletions

View File

@ -628,21 +628,20 @@ class MlogInitSerializer(CustomModelSerializer):
} }
def validate(self, attrs): def validate(self, attrs):
route: Route = attrs.get('route', None)
mgroup: Mgroup = attrs['mgroup'] mgroup: Mgroup = attrs['mgroup']
is_fix:bool = attrs.get('is_fix', False) is_fix:bool = attrs.get('is_fix', False)
attrs['mtype'] = mgroup.mtype attrs['mtype'] = mgroup.mtype
if is_fix: if is_fix:
attrs["route"] = None 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['hour_work'] = None
attrs['material_in'] = None attrs['material_in'] = None
attrs['material_out'] = 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['hour_work'] = route.hour_work
attrs['material_in'] = route.material_in attrs['material_in'] = route.material_in
attrs['material_out'] = route.material_out attrs['material_out'] = route.material_out