From 3eb760c567336c42ccddf09c8ad1dd12b93b82f2 Mon Sep 17 00:00:00 2001 From: jbw Date: Wed, 22 Dec 2021 08:31:34 +0000 Subject: [PATCH] [FIX] account: fix _compute_percentage returning > 100% Sometimes _compute_percentage would return a percentage slightly over 100 due to a rounding error. This would then trigger the constraint asserting that percentage must be >= 0 and <= 100. Task: 2717578 X-original-commit: 813d52ed7daff408819d8838c8c36fcee825905f Part-of: odoo/odoo#83732 --- addons/account/wizard/account_automatic_entry_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/account_automatic_entry_wizard.py b/addons/account/wizard/account_automatic_entry_wizard.py index b0089c07d4b..e4b4682bdfd 100644 --- a/addons/account/wizard/account_automatic_entry_wizard.py +++ b/addons/account/wizard/account_automatic_entry_wizard.py @@ -92,7 +92,7 @@ class AutomaticEntryWizard(models.TransientModel): for record in self: total = (sum(record.move_line_ids.mapped('balance')) or record.total_amount) if total != 0: - record.percentage = (record.total_amount / total) * 100 + record.percentage = min((record.total_amount / total) * 100, 100) # min() to avoid value being slightly over 100 due to rounding error else: record.percentage = 100