From 4d69358386d5ca75555a9e70364ef69bfca674dd Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 8 Nov 2023 16:43:08 -0500 Subject: [PATCH] [FIX] account: handle download unconfirmed invoice Steps to reproduce: ------------------- - create an invoice without confirm it; - go to the preview and download it; Issue: ------ A traceback appears. Cause: ------ We try to get `ids` field of a non "record" object. Solution: --------- Make sure you are in the case of an invoice that is `posted` to download a pdf. sentry-4612532780 closes odoo/odoo#141640 Signed-off-by: Laurent Smet (las) Co-authored-by: adwid --- addons/account/controllers/portal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py index 3fa31df4899..91c014e8dfb 100644 --- a/addons/account/controllers/portal.py +++ b/addons/account/controllers/portal.py @@ -131,7 +131,7 @@ class PortalAccount(CustomerPortal): except (AccessError, MissingError): return request.redirect('/my') - if report_type == 'pdf' and download: + if report_type == 'pdf' and download and invoice_sudo.state == 'posted': # Send & Print wizard with only the 'download' checkbox to get the official attachment(s) template = request.env.ref(invoice_sudo._get_mail_template()) attachment_ids = invoice_sudo._generate_pdf_and_send_invoice(template, bypass_download=True, checkbox_send_mail=False, checkbox_download=True)