From ea4ef3d20614a5f6ee929f36a804ecd1a55d12c7 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Tue, 26 May 2020 08:40:54 +0000 Subject: [PATCH] [FIX] account: make tax audit computation work with cash basis taxes https://github.com/odoo/enterprise/commit/7d17dad678361f161c259eddd45d9b5186941bd0 fixed the sign used for cash basis entries in the tax report, but this change had to be reflected on the tax_audit computed on cash basis entries as well. Before that, cash basis entries never were made on sales journals, and their move lines never had a refund-typed invoice_id. So it means those factors, when present on the original invoice, never influenced the audit string computed for cash basis entries. This was obviously wrong. closes odoo/odoo#52381 X-original-commit: 1157b3073f409c9fbdffe8f3b3322331f470de02 Related: odoo/enterprise#10927 Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/account/models/account_move.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 90aa06a9034..fec803d28a9 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3401,7 +3401,15 @@ class AccountMoveLine(models.Model): currency = record.company_id.currency_id audit_str = '' for tag in record.tax_tag_ids: - tag_amount = (tag.tax_negate and -1 or 1) * (record.move_id.is_inbound() and -1 or 1) * record.balance + + # In case of cash basis entries, we need to consider the original invoice, not the current move + if record.move_id.tax_cash_basis_rec_id: + reconciled_amls = record.move_id.tax_cash_basis_rec_id.debit_move_id + record.move_id.tax_cash_basis_rec_id.credit_move_id + invoice_aml = reconciled_amls.filtered(lambda x: x.journal_id.type in ('sale', 'purchase')) # To exclude the payment + else: + invoice_aml = record + + tag_amount = (tag.tax_negate and -1 or 1) * (invoice_aml.move_id.is_inbound() and -1 or 1) * record.balance if tag.tax_report_line_ids: #Then, the tag comes from a report line, and hence has a + or - sign (also in its name)