From 192e128e56a6e1a79d26f577ee006f230df1eb84 Mon Sep 17 00:00:00 2001 From: Adrien Widart <awt@odoo.com> Date: Fri, 19 Feb 2021 08:45:09 +0000 Subject: [PATCH] [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#66516 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> --- addons/account/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index a00f2e430a62..fca239e7959d 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -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 -- GitLab