fix: mlogbw create时进行wpr的校验
This commit is contained in:
parent
f4f17fd2b8
commit
8d4d0f7cbc
|
@ -586,9 +586,9 @@ class MlogbwCreateUpdateSerializer(CustomModelSerializer):
|
||||||
wpr:Wpr = attrs.get("wpr", None)
|
wpr:Wpr = attrs.get("wpr", None)
|
||||||
in_or_out, tracking = mlogb.get_tracking()
|
in_or_out, tracking = mlogb.get_tracking()
|
||||||
if tracking != Material.MA_TRACKING_SINGLE:
|
if tracking != Material.MA_TRACKING_SINGLE:
|
||||||
raise ValidationError('非单件追踪不可使用')
|
raise ParseError('非单件追踪不可使用')
|
||||||
if in_or_out == 'in' and not wpr:
|
if in_or_out == 'in' and not wpr:
|
||||||
raise ValidationError('请选择相应产品')
|
raise ParseError('请选择相应产品')
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def save_ftest(self, mlogbw, ftest_data):
|
def save_ftest(self, mlogbw, ftest_data):
|
||||||
|
@ -605,6 +605,11 @@ class MlogbwCreateUpdateSerializer(CustomModelSerializer):
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
|
wpr: Wpr = validated_data.get("wpr", None)
|
||||||
|
if wpr:
|
||||||
|
mlogb: Mlogb = validated_data["mlogb"]
|
||||||
|
if Mlogbw.objects.filter(mlogb=mlogb, wpr=wpr).exists():
|
||||||
|
raise ParseError('该产品已选入')
|
||||||
ftest_data = validated_data.pop("ftest", None)
|
ftest_data = validated_data.pop("ftest", None)
|
||||||
mlogbw = super().create(validated_data)
|
mlogbw = super().create(validated_data)
|
||||||
if ftest_data:
|
if ftest_data:
|
||||||
|
|
Loading…
Reference in New Issue