From 736fbc5458f68558672f4c8760831c07382dc34f Mon Sep 17 00:00:00 2001 From: Leonardo Pavan Rocha Date: Thu, 30 Sep 2021 08:38:37 +0000 Subject: [PATCH] [IMP] web: add url_parse in report download to get data from URL When printing particular reports without specified record IDs, an indexError occurs, therefore preventing the printing. This PR changes the way the data is get from the url by using url_parse instead of string.split('?'), which sets the data to an empty dictionary if no params exist in the url. task-2552160 closes odoo/odoo#77471 Related: odoo/upgrade#2694 Related: odoo/enterprise#19808 Signed-off-by: Arnaud Joset --- addons/web/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e510bd6e4e2..fc79c8de046 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -26,7 +26,7 @@ import werkzeug.wrappers import werkzeug.wsgi from lxml import etree, html from markupsafe import Markup -from werkzeug.urls import url_encode, url_decode, iri_to_uri +from werkzeug.urls import url_encode, url_parse, iri_to_uri import odoo import odoo.modules.registry @@ -1998,7 +1998,7 @@ class ReportController(http.Controller): response = self.report_routes(reportname, docids=docids, converter=converter, context=context) else: # Particular report: - data = dict(url_decode(url.split('?')[1]).items()) # decoding the args represented in JSON + data = url_parse(url).decode_query(cls=dict) # decoding the args represented in JSON if 'context' in data: context, data_context = json.loads(context or '{}'), json.loads(data.pop('context')) context = json.dumps({**context, **data_context})