From 03d2e457b69b07f315187cd7f7299be4c838e177 Mon Sep 17 00:00:00 2001 From: Adrien Widart <awt@odoo.com> Date: Tue, 23 Feb 2021 14:34:47 +0000 Subject: [PATCH] [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#66706 Signed-off-by: Adrien Widart <adwid@users.noreply.github.com> --- addons/account/models/ir_actions_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index fca239e7959d..78b21f0a9f9e 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 -- GitLab