From c771aa406c2d8b457a031db1e247a7e6f0106d38 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 31 Aug 2022 13:05:37 +0000 Subject: [PATCH] [FIX] website, website_blog: fix wrong href on the top banner of /blog Before this commit, following these steps: - Go to /blog - Activate the option Customize > Top banner - Name / Latest Post - Disable the option Customize > Full Width Cover The URL to which we are redirected when we click on the category of the post presented at the top of the page leads to an error. In order to fix the wrong url we had to patch QueryURL so that the url prefix is added only if the url does not already start with the prefix. opw-2882492 X-original-commit: https://github.com/odoo/odoo/commit/2b326de107b9b7a2013ee9ff174d81b645d6a623 Part-of: odoo/odoo#104639 --- addons/website/controllers/main.py | 5 ++++- addons/website_blog/controllers/main.py | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 94bfd5f0d6d..af6554f483c 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -43,7 +43,8 @@ class QueryURL(object): self.path_args = OrderedSet(path_args or []) def __call__(self, path=None, path_args=None, **kw): - path = path or self.path + path_prefix = path or self.path + path = '' for key, value in self.args.items(): kw.setdefault(key, value) path_args = OrderedSet(path_args or []) | self.path_args @@ -65,6 +66,8 @@ class QueryURL(object): path += '/' + key + '/' + value if fragments: path += '?' + '&'.join(fragments) + if not path.startswith(path_prefix): + path = path_prefix + path return path diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index 5a03b067282..902eee77535 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -215,9 +215,7 @@ class WebsiteBlog(http.Controller): if blog: values['main_object'] = blog - values['blog_url'] = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end, search=search) - else: - values['blog_url'] = QueryURL('/blog', ['tag'], date_begin=date_begin, date_end=date_end, search=search) + values['blog_url'] = QueryURL('/blog', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end, search=search) return request.render("website_blog.blog_post_short", values)