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)