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)