[FIX] account: use proforma preview for non-printed invoices
Issue ----- If an invoice is created, but not yet "Send & Print", the portal preview shows a normal invoice, but when "Download"ed from the portal preview, a proforma invoice is downloaded. The download behavior is intended since the client shouldn't be able to get a "final" invoice themselves, before the accountant generates one with "Send & Print". However, the HTML preview should also show a proforma invoice to be consistent with this, so the user downloads what they see. Steps ----- - Create a new invoice: Accounting -> Customers -> Invoices -> New -> ... - Go to portal by clicking on "Preview". - You'll see a normal invoice. Now click "Download". - A proforma invoice is downloaded. Cause ----- The HTML-rendered invoice in the portal preview isn't configured to be proforma. opw-3848049 closes odoo/odoo#161726 Signed-off-by: Claire Bretton (clbr) <clbr@odoo.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user