From 3561a50647cdd61c10f57faa663f9e772fcdc2ca Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 23 Jul 2026 09:15:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BFRoute?= =?UTF-8?q?=E5=88=9B=E5=BB=BA/=E6=9B=B4=E6=96=B0=E6=97=B6=E6=9C=AA?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E8=BE=93=E5=87=BA=E7=89=A9=E6=96=99=E4=B8=94?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=8C=85=E6=97=A0=E4=BA=A7=E5=93=81=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=8A=A5=E9=94=99,=E4=B8=8D=E5=86=8D=E9=9D=99?= =?UTF-8?q?=E9=BB=98=E7=94=9F=E6=88=90=E6=AE=8B=E7=BC=BA=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?;=E8=A1=A5material=5Fin=5Ftype=E5=AD=97=E6=AE=B5=E4=BE=9B?= =?UTF-8?q?=E7=94=BB=E5=B8=83=E6=8C=89=E7=89=A9=E6=96=99=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9D=80=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- apps/mtm/serializers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/mtm/serializers.py b/apps/mtm/serializers.py index 99beed56..5af9de02 100644 --- a/apps/mtm/serializers.py +++ b/apps/mtm/serializers.py @@ -177,6 +177,8 @@ class RouteSerializer(CustomModelSerializer): process_cate = serializers.CharField(source='process.cate', read_only=True) material_in_name = serializers.StringRelatedField( source='material_in', read_only=True) + material_in_type = serializers.CharField( + source='material_in.type', read_only=True) material_out_name = serializers.StringRelatedField( source='material_out', read_only=True) material_out_type = serializers.CharField( @@ -268,6 +270,8 @@ class RouteSerializer(CustomModelSerializer): # if material and process and Route.objects.filter(material=material, process=process).exists(): # raise ValidationError('已选择该工序!!') + if not validated_data.get('material_out') and not validated_data.get('material'): + raise ParseError('未指定输出物料,且工艺包未设置产品无法自动生成;请指定输出物料,或先在工艺包基本信息中选择产品') instance:Route = super().create(validated_data) material_out = instance.material_out if material_out: @@ -303,6 +307,8 @@ class RouteSerializer(CustomModelSerializer): if material_out_tracking is None: material_out_tracking = Material.MA_TRACKING_BATCH + if not validated_data.get('material_out', instance.material_out) and not instance.material: + raise ParseError('未指定输出物料,且工艺包未设置产品无法自动生成;请指定输出物料,或先在工艺包基本信息中选择产品') instance = super().update(instance, validated_data) material_out = instance.material_out if material_out: