[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 <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
oco-odoo
2020-06-03 16:59:16 +00:00
parent 564a1b94a7
commit ea4ef3d206
+9 -1
View File
@@ -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)