From b522ab5772e19c41ea47484b80bca0dc054859a6 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 8 Mar 2018 10:42:31 +0100 Subject: [PATCH] [FIX] account: tax rounding - Set 'Round Globally' - Create an excluded tax of 10 % - Create an invoice for a product costing 34.55, and apply the tax. The tax on the invoice is 3.46, while the tax on the tax line is 3.45. When rounded in `compute_all`, the tax amount is 3.455, which is the value expected. However, the `create` method won't round this value before storing, leading to the inconsistency. We make sure to round the amount to the currency precision, so the value 3.46 is recorded. opw-1819902 --- addons/account/models/account_invoice.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 89348f2dacc..7939d463a3c 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1410,7 +1410,14 @@ class AccountInvoiceTax(models.Model): currency_id = fields.Many2one('res.currency', related='invoice_id.currency_id', store=True, readonly=True) base = fields.Monetary(string='Base', compute='_compute_base_amount') - + # DO NOT FORWARD-PORT!!! ONLY FOR v10 + def create(self, vals): + inv_tax = super(AccountInvoiceTax, self).create(vals) + # Workaround to make sure the tax amount is rounded to the currency precision since the ORM + # won't round it automatically at creation. + if inv_tax.company_id.tax_calculation_rounding_method == 'round_globally': + inv_tax.amount = inv_tax.currency_id.round(inv_tax.amount) + return inv_tax class AccountPaymentTerm(models.Model):