Skip to Content
Menu
This question has been flagged
2 Replies
1008 Views

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
267
1
Oct 24
335
4
Oct 24
326
2
Oct 24
362
2
Dec 24
671