feat: mio pur test 支持count_sampling自填
This commit is contained in:
parent
3bb3834c04
commit
27c60ff973
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue