From 8aaab680a9db7437c5a076a5d59a19e44e84a06d Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 11 Jul 2019 09:10:46 +0000 Subject: [PATCH] [FIX] account_voucher: handle tax included in round globally Have a Tax 24%, included Have account.voucher with a line reading: `Price: 64.93; Tax: 24% Incl` Validate the voucher Before this commit, the account.move.lines created were wrong and unbalanced as the amounts that should have been affected by the tax included haven't been After this commit, the move and its lines are correct and balanced OPW 2031751 closes odoo/odoo#34784 Signed-off-by: Lucas Perais (lpe) --- addons/account_voucher/models/account_voucher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/account_voucher/models/account_voucher.py b/addons/account_voucher/models/account_voucher.py index e9eca30907a..92a291af5b1 100644 --- a/addons/account_voucher/models/account_voucher.py +++ b/addons/account_voucher/models/account_voucher.py @@ -341,11 +341,16 @@ class AccountVoucher(models.Model): # When global rounding is activated, we must wait until all tax lines are computed to # merge them. if tax_calculation_rounding_method == 'round_globally': - self.env['account.move.line'].create(move_line) + # _apply_taxes modifies the dict move_line in place to account for included/excluded taxes tax_lines_vals += self.env['account.move.line'].with_context(round=False)._apply_taxes( move_line, move_line.get('debit', 0.0) - move_line.get('credit', 0.0) ) + # rounding False means the move_line's amount are not rounded + currency = self.env['res.currency'].browse(company_currency) + move_line['debit'] = currency.round(move_line['debit']) + move_line['credit'] = currency.round(move_line['credit']) + self.env['account.move.line'].create(move_line) else: self.env['account.move.line'].with_context(apply_taxes=True).create(move_line)