From 840b1c5e74792b57737810afbaabef699624ac99 Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Wed, 23 Aug 2023 17:02:53 +0200 Subject: [PATCH] Only try to render invoices of type 'out' and in posted/paid state. Move the check to generated_facturae. --- invoice.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/invoice.py b/invoice.py index 88bd23d..da3c433 100644 --- a/invoice.py +++ b/invoice.py @@ -255,6 +255,8 @@ class Invoice(metaclass=PoolMeta): config = Configuration(1) transaction = Transaction() + if self.type != 'out' or self.state not in ('posted', 'paid'): + return # send facturae to service if not service and config.facturae_service: service = config.facturae_service @@ -301,11 +303,6 @@ class Invoice(metaclass=PoolMeta): Date = pool.get('ir.date') Rate = pool.get('currency.currency.rate') - if self.type != 'out': - return - if self.state not in ('posted', 'paid'): - return - # These are an assert because it shouldn't happen assert self.invoice_date <= Date.today(), ( "Invoice date of invoice %s is in the future" % self.id)