New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] website: language prefixed URL on website #31792
Conversation
caa428d
to
75b72e8
Compare
75b72e8
to
bb9100f
Compare
bb9100f
to
0abad90
Compare
0abad90
to
10e1b98
Compare
Hi @KangOl Do you think the test is okay for this PR, it is a lot hackish since I test low-level function and in def is_multilang_url(local_url, langs=None):
# ...
router = request.httprequest.app.get_db_router(request.db).bind('')
# Force to check method to POST. Odoo uses methods : ['POST'] and ['GET', 'POST']
func = router.match(path, method='POST', query_args=query_string)[0]
return (func.routing.get('website', False) and
func.routing.get('multilang', func.routing['type'] == 'http')) |
I would put the test(s) in its own class, set the initialization in |
10e1b98
to
e67f4fd
Compare
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if `fr_FR` language (french) is installed and not the default website language we would have all URL towards translated content (route with multilang=True) prefixed with /fr_FR/ (the language code). With 9cd982b some improvments were done to CDN but this also breaks language prefixing, so this cause an unecessary redirect: - we are on /fr_FR/contact and click on "Shop" - we go to /shop - odoo redirects US /fr_FR/shop With this PR, URLs are prefixed with language once again. note: the added test is hackish but the function tested depends on a lot of odoo.http things that are hard to use for test (request.render, request.context, request.httpreqest). opw-1922051 closes odoo#31792
e67f4fd
to
dcd114e
Compare
@KangOl ok, it is done I will merge on monday if there is no other comment |
Actually, trust robodoo |
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if `fr_FR` language (french) is installed and not the default website language we would have all URL towards translated content (route with multilang=True) prefixed with /fr_FR/ (the language code). With 9cd982b some improvments were done to CDN but this also breaks language prefixing, so this cause an unecessary redirect: - we are on /fr_FR/contact and click on "Shop" - we go to /shop - odoo redirects US /fr_FR/shop With this PR, URLs are prefixed with language once again. note: the added test is hackish but the function tested depends on a lot of odoo.http things that are hard to use for test (request.render, request.context, request.httpreqest). opw-1922051 closes #31792 Signed-off-by: Christophe Simonis <chs@odoo.com>
With 953a693 when a route is not found we assume it is a website.page that can be multilang. But with odoo#31792 we should once again prefix URL by the language if necessary. The combination of the two cause issue when an url like `/web#home` is tested since we do not take `#` into account, we check if the route is multilang but no route `/web#home` is found => so we get `/fr_FR/web#home`. With this fix, `#fragment` is not taken into account when searching route. related to odoo#31792 related to opw-1922051 closes odoo#32059
With 953a693 when a route is not found we assume it is a website.page that can be multilang. But with #31792 we should once again prefix URL by the language if necessary. The combination of the two cause issue when an url like `/web#home` is tested since we do not take `#` into account, we check if the route is multilang but no route `/web#home` is found => so we get `/fr_FR/web#home`. With this fix, `#fragment` is not taken into account when searching route. related to #31792 related to opw-1922051 closes #32059 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Merged, thanks! |
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if
fr_FR
language (french) is installed and not the default websitelanguage we would have all URL towards translated content (route with
multilang=True) prefixed with /fr_FR/ (the language code).
With 9cd982b some improvments were done to CDN but this also breaks
language prefixing, so this cause an unecessary redirect:
With this PR, URLs are prefixed with language once again.
note: the added test is hackish but the function tested depends on a lot
of odoo.http things that are hard to use for test (request.render,
request.context, request.httpreqest).
opw-1922051