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

[FIX] account: set main attachment only for posted invoices


When printing a draft invoice, it raises an error.

The error comes from fix #65320: the latter registers the printed
invoice as main attachment, but this needs to be done only with posted
invoices.

OPW-2427247

closes odoo/odoo#66526

X-original-commit: 192e128e
Signed-off-by: default avatarLaurent Smet <smetl@users.noreply.github.com>
Signed-off-by: default avatarAdrien Widart <adwid@users.noreply.github.com>
parent 363bc68a
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,6 @@ class IrActionsReport(models.Model):
if self.report_name == 'account.report_original_vendor_bill':
return None
res = super(IrActionsReport, self)._postprocess_pdf_report(record, buffer)
if self.model == 'account.move' and record.is_sale_document(include_receipts=True):
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)
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