diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index fca239e7959d0a5748c4f7ee1fc6a96726865f20..78b21f0a9f9ec047aa2ff4c6d6cf12cdfb146464 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