diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 5f4d5cffb40..c59286cf381 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -143,6 +143,8 @@ class PortalAccount(CustomerPortal): return request.make_response(attachments.raw, list(headers.items())) elif report_type in ('html', 'pdf', 'text'): + has_generated_invoice = bool(invoice_sudo.invoice_pdf_report_id) + request.update_context(proforma_invoice=not has_generated_invoice) return self._show_report(model=invoice_sudo, report_type=report_type, report_ref='account.account_invoices', download=download) values = self._invoice_get_page_view_values(invoice_sudo, access_token, **kw) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index a1d46948c50..b2216f0eb1b 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -75,3 +75,9 @@ class IrActionsReport(models.Model): master_report = self.env.ref(f"account.{master_xmlid}", raise_if_not_found=False) if master_report and master_report in self: raise UserError(_("You cannot delete this report (%s), it is used by the accounting PDF generation engine.", master_report.name)) + + def _get_rendering_context(self, report, docids, data): + data = super()._get_rendering_context(report, docids, data) + if self.env.context.get('proforma_invoice'): + data['proforma'] = True + return data