From 66856c197c4b56f0e00a1d8b117e7560a54b0d64 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 6 Apr 2020 13:05:05 +0200 Subject: [PATCH] Exclude refunds from cancelled invoices on ES VAT List issue9097 review289441002 --- reporting_tax.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reporting_tax.py b/reporting_tax.py index a82d100a37..38a46df49a 100644 --- a/reporting_tax.py +++ b/reporting_tax.py @@ -429,6 +429,7 @@ class ESVATList(ModelSQL, ModelView): Date = pool.get('ir.date') context = Transaction().context invoice = Invoice.__table__() + cancel_invoice = Invoice.__table__() invoice_tax = InvoiceTax.__table__() tax = Tax.__table__() tax_code = TaxCode.__table__() @@ -450,6 +451,9 @@ class ESVATList(ModelSQL, ModelView): & (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))) # Use exists to exclude the full invoice when it has multiple taxes & ~Exists(exclude_invoice_tax.select( exclude_invoice_tax.invoice,