[FIX] account: fallback on missing template

template contains the mail template to render and is the result of the call to
`self.env.ref('account.email_template_edi_invoice', False)`

If the template does not exists (deleted), template is `None` and the action
rendering crashes.
While it is not recommended to delete master data, it is still possible to use
custom mail templates.

Closes #15204
This commit is contained in:
sergio 2017-01-24 15:12:24 +01:00 committed by Martin Trigaux
parent 333f012e25
commit 28ec23e828
No known key found for this signature in database
GPG Key ID: 7B0E288E7C0F83A7
1 changed files with 1 additions and 1 deletions

View File

@ -395,7 +395,7 @@ class account_invoice(models.Model):
default_model='account.invoice',
default_res_id=self.id,
default_use_template=bool(template),
default_template_id=template.id,
default_template_id=template and template.id or False,
default_composition_mode='comment',
mark_invoice_as_sent=True,
)