From 24307e27f54d90363b3236488ffe604e0bedbc6a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 10 Dec 2021 14:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E6=A3=80=E6=8F=90=E4=BE=9B=E5=8E=9F?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=AE=B0=E5=BD=95ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/serializers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py index cb687e8..154c2d5 100644 --- a/hb_server/apps/wpm/serializers.py +++ b/hb_server/apps/wpm/serializers.py @@ -288,10 +288,18 @@ class WpmTestRecordCreateSerializer(serializers.ModelSerializer): record_data = WpmTestRecordItemCreateSerializer(many=True) wproduct = serializers.PrimaryKeyRelatedField(queryset=WProduct.objects.all(), required=True) is_testok = serializers.BooleanField(required=False) - class Meta: model = TestRecord - fields = ['form', 'record_data', 'is_testok', 'wproduct'] + fields = ['form', 'record_data', 'is_testok', 'wproduct', 'origin_test'] + + def validate(self, attrs): + wproduct = attrs['wproduct'] + if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: + if 'origin_test' in attrs and attrs['origin_test']: + pass + else: + raise exceptions.APIException('复检需提供原检测记录ID') + return super().validate(attrs) class WpmTestFormInitSerializer(serializers.Serializer): wproduct = serializers.PrimaryKeyRelatedField(queryset=WProduct.objects.all(), required=True)