From 649eedaa2ec79d1178cd28d9b9438ac275c9fb62 Mon Sep 17 00:00:00 2001 From: Adrien Widart 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#66563 X-original-commit: 49a57dd5b34b66733564b31ed861fe9bfcbda2b3 Signed-off-by: Laurent Smet Signed-off-by: Adrien Widart --- 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 e3ee7814b22..1b2a529692c 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