changeset 8a0ea25542ad in modules/account_es:5.6 details: https://hg.tryton.org/modules/account_es?cmd=changeset&node=8a0ea25542ad description: Do not ignore invoice cancelled by a credit note
issue10030 review348231002 (grafted from 0a742f78ab11d8a45bc583e76058ed3c56c86fab) diffstat: reporting_tax.py | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diffs (36 lines): diff -r 647ba16ece17 -r 8a0ea25542ad reporting_tax.py --- a/reporting_tax.py Mon Feb 01 23:31:48 2021 +0100 +++ b/reporting_tax.py Thu Apr 29 11:20:15 2021 +0200 @@ -425,10 +425,12 @@ TaxCode = pool.get('account.tax.code') TaxCodeLine = pool.get('account.tax.code.line') Date = pool.get('ir.date') + Move = pool.get('account.move') context = Transaction().context invoice = Invoice.__table__() cancel_invoice = Invoice.__table__() invoice_tax = InvoiceTax.__table__() + cancel_move = Move.__table__() tax = Tax.__table__() tax_code = TaxCode.__table__() tax_code_line = TaxCodeLine.__table__() @@ -445,13 +447,15 @@ where=tax_code.aeat_report.in_(cls.excluded_tax_codes()))) where = ((invoice.company == context.get('company')) - & (invoice.state.in_(['posted', 'paid'])) & (tax.es_vat_list_code != Null) & (Extract('year', invoice.invoice_date) == context.get('date', Date.today()).year) - & ~Exists(cancel_invoice.select( - cancel_invoice.cancel_move, distinct=True, - where=(cancel_invoice.cancel_move == invoice.move))) + & ~Exists(cancel_invoice + .join(cancel_move, + condition=cancel_invoice.cancel_move == cancel_move.id) + .select(cancel_invoice.id, distinct=True, + where=((cancel_invoice.id == invoice.id) + & (~cancel_move.origin.like('account.invoice,%'))))) # Use exists to exclude the full invoice when it has multiple taxes & ~Exists(exclude_invoice_tax.select( exclude_invoice_tax.invoice,