fix: routeserializer优化routepack process校验3

This commit is contained in:
caoqianming 2024-08-02 11:14:45 +08:00
parent f5482285f2
commit 313e9ed1cd
1 changed files with 3 additions and 2 deletions

View File

@ -215,8 +215,9 @@ class RouteSerializer(CustomModelSerializer):
def create(self, validated_data):
process = validated_data['process']
routepack = validated_data.get('routepack', None)
if routepack and Route.objects.filter(routepack=routepack, process=process).exists():
raise ValidationError('已选择该工序!')
if routepack:
if 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():