Only try to render invoices of type 'out' and in posted/paid state. Move the check to generated_facturae.

This commit is contained in:
Albert Cervera i Areny 2023-08-23 17:02:53 +02:00
parent a5bf6fb2f6
commit 840b1c5e74
1 changed files with 2 additions and 5 deletions

View File

@ -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)