From be8fc2296b3822baffe0bc68cb4b7efdfe53fa91 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 12 Sep 2019 09:45:11 +0000 Subject: [IMP] base, http_routing, website: allow custom routing rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After this commit, you will be able (in technical mode) to update the url for the python controllers. Eg. You can now rename /shop in /garden and /shop/product/ in /garden/vegetable/ Most of urls will be replaced at fly in the renderd qweb, with the function url_for but all old urls will keep available. So if you access url /shop you will be automatically redirected to /garden (308 Permanent Redirect). As for cdn and other post-process of att, the automatically replacement in the rendered qweb is only done when you will be not website editor. But the new dispatch of URL will be applied in all cases. For developper, since it is Permanent Redirect, don't forget to clear cache or open chrome debug tool (with option 'Disable cache while DevTools is Open) to see your lasts changes. closes odoo/odoo#36555 Signed-off-by: Jérémy Kersten (jke) --- addons/website/tests/test_lang_url.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/website/tests/test_lang_url.py') diff --git a/addons/website/tests/test_lang_url.py b/addons/website/tests/test_lang_url.py index f4998168074..871248c2778 100644 --- a/addons/website/tests/test_lang_url.py +++ b/addons/website/tests/test_lang_url.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.http_routing.models.ir_http import url_for +from odoo.addons.http_routing.models.ir_http import url_lang from odoo.addons.website.tools import MockRequest from odoo.tests import HttpCase, tagged @@ -18,9 +18,9 @@ class TestLangUrl(HttpCase): self.website.language_ids = self.env.ref('base.lang_en') + lang_fr self.website.default_lang_id = self.env.ref('base.lang_en') - def test_01_url_for(self): + def test_01_url_lang(self): with MockRequest(self.env, website=self.website): - self.assertEqual(url_for('', '[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' -- cgit v1.2.3