[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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user