feat: 优化mloginit报错提示

This commit is contained in:
caoqianming 2025-02-06 16:56:06 +08:00
parent 77a50ae162
commit 622d594795
1 changed files with 4 additions and 2 deletions

View File

@ -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