feat: mlogbupdate 校验
This commit is contained in:
parent
bbac19c791
commit
ad1d0680b1
|
|
@ -417,9 +417,20 @@ class MlogbInUpdateSerializer(CustomModelSerializer):
|
|||
class MlogbOutUpdateSerializer(CustomModelSerializer):
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'batch', 'count_real', 'count_ok', 'count_notok',
|
||||
'count_n_hs', 'count_n_qp', 'count_n_swen', 'count_n_bb',
|
||||
'count_n_wm', 'count_n_md', 'count_n_xh']
|
||||
fields = "__all__"
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ['mlog', 'mtask', 'wm_in', 'material_in', 'material_out', 'count_use', 'count_break']
|
||||
|
||||
def validate(self, attrs):
|
||||
count_notok = 0
|
||||
for i in attrs:
|
||||
if 'count_n_' in i:
|
||||
count_notok = count_notok + attrs[i]
|
||||
attrs['count_notok'] = count_notok
|
||||
if attrs['count_real'] >= attrs['count_ok'] + attrs['count_notok']:
|
||||
pass
|
||||
else:
|
||||
raise ValidationError('生产数量不能小于合格数量')
|
||||
return attrs
|
||||
|
||||
class MlogRevertSerializer(serializers.Serializer):
|
||||
change_reason = serializers.CharField(label='撤回原因')
|
||||
|
|
|
|||
Loading…
Reference in New Issue