From adffac48ad797dcd306510bab4a1786f95477129 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 2 Aug 2024 09:13:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20routeserializer=E4=BC=98=E5=8C=96routepa?= =?UTF-8?q?ck=20process=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mtm/serializers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/mtm/serializers.py b/apps/mtm/serializers.py index c2ab5add..6098234b 100644 --- a/apps/mtm/serializers.py +++ b/apps/mtm/serializers.py @@ -214,9 +214,13 @@ class RouteSerializer(CustomModelSerializer): def create(self, validated_data): process = validated_data['process'] - material = validated_data.get('material', None) - if material and process and Route.objects.filter(material=material, process=process).exists(): + routepack = validated_data.get('routepack', None) + if routepack and Route.objects.filter(routepack=routepack, process=process).exists(): raise ValidationError('已选择该工序') + else: + material = validated_data.get('material', None) + if material and process and Route.objects.filter(material=material, process=process).exists(): + raise ValidationError('已选择该工序') with transaction.atomic(): instance = super().create(validated_data) material_out = instance.material_out