跳至內容
選單
此問題已被標幟
2 回覆
1514 瀏覽次數

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', }

頭像
捨棄
最佳答案

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

頭像
捨棄
最佳答案

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.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
8月 25
2647
1
7月 25
1032
1
8月 25
1151
0
5月 25
1490
2
4月 25
3645