diff options
| author | Adrien Widart <awt@odoo.com> | 2021-02-23 14:34:47 +0000 |
|---|---|---|
| committer | Adrien Widart <awt@odoo.com> | 2021-02-24 11:28:55 +0000 |
| commit | 00b573c5b14dcf50ab5ed1612b1490bb75a6f6b1 (patch) | |
| tree | 57f5a43db9ab64bf4f4f374dad162f5aa47cb5db /addons/account/models/ir_actions_report.py | |
| parent | 911aec8465a4a796297a465e96b3033d1c415628 (diff) | |
[FIX] account: register attachment only if it exists
When printing an invoice, the server tries to register one attachment as
main one (see #65320). However, if there is not any attachment, this
will raise an error.
OPW-2465995
closes odoo/odoo#66747
X-original-commit: 03d2e457b69b07f315187cd7f7299be4c838e177
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
Diffstat (limited to 'addons/account/models/ir_actions_report.py')
| -rw-r--r-- | addons/account/models/ir_actions_report.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index 1b2a529692c..27deaa9fe7e 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -29,5 +29,7 @@ class IrActionsReport(models.Model): return None res = super(IrActionsReport, self)._postprocess_pdf_report(record, buffer) if self.model == 'account.move' and record.state == 'posted' and record.is_sale_document(include_receipts=True): - self.retrieve_attachment(record).register_as_main_attachment(force=False) + attachment = self.retrieve_attachment(record) + if attachment: + attachment.register_as_main_attachment(force=False) return res |
