Skip to content
Snippets Groups Projects
Commit 03d2e457 authored by Adrien Widart's avatar Adrien Widart
Browse files

[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: default avatarAdrien Widart <adwid@users.noreply.github.com>
parent 4ceb056a
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment