Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1506 Lượt xem

When i enter 10 the value is recorded but when i enter 10.55 is not recorded. How to resolve it ?

def save_contract_completion(self): total_weightage = 0 for line in self.stage_details_ids: total_weightage += line.stage_weightage if total_weightage <= 0: raise ValidationError( f'The total of stage weightage is %s' % (total_weightage) + '%. \nPlease, re-set the weightage of each stage.' ) elif total_weightage > 100: raise ValidationError( f'The total of stage weightage is more than 100%.\nPlease, re-set the weightage of each stage.') elif total_weightage < 100: return{ 'name': ("Confirmation"), 'type': 'ir.actions.act_window', 'res_model': 'contract.completion.validation.wizard', 'view_mode': 'form', 'target': 'new', 'context': {'default_contract_completion_id': self.id,} } else: return { 'type': 'ir.actions.act_window_close', }

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try this way

Field :-

stage_weightage = fields.Float(‘Stage Weightage’)

Function:-

def save_contract_completion(self):
total_weightage = 0
for line in self.stage_details_ids:
total_weightage += line.stage_weightage
if total_weightage <= float(0):
raise ValidationError(f'The total of stage weightage is %s' % (
total_weightage) + '%. \nPlease, re-set the weightage of each stage.')
elif total_weightage > float(100):
raise ValidationError(
f'The total of stage weightage is more than 100%.\nPlease, re-set the weightage of each stage.')
elif total_weightage < float(100):
return {'name': ("Confirmation"),
'type': 'ir.actions.act_window',
'res_model': 'contract.completion.validation.wizard', 'view_mode': 'form',
'target': 'new',
'context': {'default_contract_completion_id': self.id, }}
else: return {'type': 'ir.actions.act_window_close', }

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

The problem is that when you created the field you created an integer field instead of a float field.

You should delete that field and create a new one.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2644
1
thg 7 25
1029
1
thg 8 25
1151
0
thg 5 25
1488
2
thg 4 25
3643