[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
This commit is contained in:
jbw
2022-02-01 10:54:36 +00:00
parent ecf66e6507
commit 3eb760c567
@@ -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