From 27c60ff9735fc6fef1d040813005821544027a57 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 13 Aug 2024 17:28:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mio=20pur=20test=20=E6=94=AF=E6=8C=81co?= =?UTF-8?q?unt=5Fsampling=E8=87=AA=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/serializers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/inm/serializers.py b/apps/inm/serializers.py index 760fe0b0..3d97cacc 100644 --- a/apps/inm/serializers.py +++ b/apps/inm/serializers.py @@ -284,14 +284,17 @@ class MIOItemPurInTestSerializer(CustomModelSerializer): class Meta: model = MIOItem fields = ['id', 'test_date', 'test_user', - 'count_bag', 'weight_kgs', 'is_testok', 'test_note'] + 'count_bag', 'count_sampling' 'weight_kgs', 'is_testok', 'test_note'] extra_kwargs = { 'test_date': {'required': True}, 'test_user': {'required': True} } def validate(self, attrs): - weight_kgs = attrs['weight_kgs'] - attrs['weight_kgs'] = [float(i) for i in weight_kgs] - attrs['count_sampling'] = len(attrs['weight_kgs']) + if 'count_sampling' in attrs and attrs['count_sampling']: + pass + else: + weight_kgs = attrs['weight_kgs'] + attrs['weight_kgs'] = [float(i) for i in weight_kgs] + attrs['count_sampling'] = len(attrs['weight_kgs']) return super().validate(attrs)