diff --git a/addons/http_routing/controllers/main.py b/addons/http_routing/controllers/main.py index dd57e485b10..4a55c86a0b1 100644 --- a/addons/http_routing/controllers/main.py +++ b/addons/http_routing/controllers/main.py @@ -3,7 +3,7 @@ from odoo import http from odoo.http import request -from odoo.addons.web.controllers.main import WebClient, Home +from odoo.addons.web.controllers.main import WebClient, Home, Session class Routing(Home): @@ -15,3 +15,10 @@ class Routing(Home): if mods: modules += mods return WebClient().translations(unique, mods=','.join(modules), lang=lang) + + +class SessionWebsite(Session): + + @http.route('/web/session/logout', type='http', auth="none", website=True, multilang=False, sitemap=False) + def logout(self, redirect='/web'): + return super().logout(redirect=redirect) diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index 92b65214f36..4af5053e69d 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -166,7 +166,12 @@ def url_lang(path_or_uri, lang_code=None): # Insert the context language or the provided language elif lang_url_code != default_lg.url_code or force_lang: ps.insert(1, lang_url_code) - location = u'/'.join(ps) + sep + qs + + # remove trailing / + # ['', fr', ''] => /fr/ instead of /fr + if ps[-1] == '': + ps.pop(-1) + location = (u'/'.join(ps) or u'/') + sep + qs return location diff --git a/addons/website/tests/test_lang_url.py b/addons/website/tests/test_lang_url.py index bd021fd66a9..98a8de4b974 100644 --- a/addons/website/tests/test_lang_url.py +++ b/addons/website/tests/test_lang_url.py @@ -22,7 +22,7 @@ class TestLangUrl(HttpCase): def test_01_url_lang(self): with MockRequest(self.env, website=self.website): - self.assertEqual(url_lang('', '[lang]'), '/[lang]/hello/', "`[lang]` is used to be replaced in the url_return after installing a language, it should not be replaced or removed.") + self.assertEqual(url_lang('', '[lang]'), '/[lang]/hello', "`[lang]` is used to be replaced in the url_return after installing a language, it should not be replaced or removed.") def test_02_url_redirect(self): url = '/fr_WHATEVER/contactus' diff --git a/addons/website/tests/test_qweb.py b/addons/website/tests/test_qweb.py index c358b52184b..8c1dc4d82af 100644 --- a/addons/website/tests/test_qweb.py +++ b/addons/website/tests/test_qweb.py @@ -114,8 +114,8 @@ class TestQwebProcessAtt(TransactionCase): def test_process_att_no_request(self): # no request so no URL rewriting self._test_att('/', {'href': '/'}) - self._test_att('/en/', {'href': '/en/'}) - self._test_att('/fr/', {'href': '/fr/'}) + self._test_att('/en', {'href': '/en'}) + self._test_att('/fr', {'href': '/fr'}) # no URL rewritting for CDN self._test_att('/a', {'href': '/a'}) @@ -123,8 +123,8 @@ class TestQwebProcessAtt(TransactionCase): with MockRequest(self.env): # no website so URL rewriting self._test_att('/', {'href': '/'}) - self._test_att('/en/', {'href': '/en/'}) - self._test_att('/fr/', {'href': '/fr/'}) + self._test_att('/en', {'href': '/en'}) + self._test_att('/fr', {'href': '/fr'}) # no URL rewritting for CDN self._test_att('/a', {'href': '/a'}) @@ -140,13 +140,15 @@ class TestQwebProcessAtt(TransactionCase): with MockRequest(self.env, website=self.website): self._test_att('/', {'href': '/'}) self._test_att('/en/', {'href': '/'}) - self._test_att('/fr/', {'href': '/fr/'}) + self._test_att('/fr/', {'href': '/fr'}) + self._test_att('/fr', {'href': '/fr'}) def test_process_att_with_request_lang(self): with MockRequest(self.env, website=self.website, context={'lang': 'fr_FR'}): - self._test_att('/', {'href': '/fr/'}) + self._test_att('/', {'href': '/fr'}) self._test_att('/en/', {'href': '/'}) - self._test_att('/fr/', {'href': '/fr/'}) + self._test_att('/fr/', {'href': '/fr'}) + self._test_att('/fr', {'href': '/fr'}) def test_process_att_matching_cdn_and_lang(self): with MockRequest(self.env, website=self.website):