Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
1516 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
août 25
2651
1
juil. 25
1032
1
août 25
1151
0
mai 25
1491
2
avr. 25
3645