feat: mio pur test 支持count_sampling自填
This commit is contained in:
parent
3bb3834c04
commit
27c60ff973
|
@ -284,13 +284,16 @@ class MIOItemPurInTestSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MIOItem
|
model = MIOItem
|
||||||
fields = ['id', 'test_date', 'test_user',
|
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 = {
|
extra_kwargs = {
|
||||||
'test_date': {'required': True},
|
'test_date': {'required': True},
|
||||||
'test_user': {'required': True}
|
'test_user': {'required': True}
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
if 'count_sampling' in attrs and attrs['count_sampling']:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
weight_kgs = attrs['weight_kgs']
|
weight_kgs = attrs['weight_kgs']
|
||||||
attrs['weight_kgs'] = [float(i) for i in weight_kgs]
|
attrs['weight_kgs'] = [float(i) for i in weight_kgs]
|
||||||
attrs['count_sampling'] = len(attrs['weight_kgs'])
|
attrs['count_sampling'] = len(attrs['weight_kgs'])
|
||||||
|
|
Loading…
Reference in New Issue