summaryrefslogtreecommitdiff
path: root/addons/website/models
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2021-04-19 16:18:30 +0000
committerRomain Derie <rde@odoo.com>2021-04-27 09:49:34 +0000
commit733411fe03b924832d6b10cadf93c8fc09cc5802 (patch)
treedd6d45be0e00857fb3c3dd07f20435b3ff1796a8 /addons/website/models
parent8d452ae16b7e6c3077d9eae135852bada43cec93 (diff)
[FIX] website: use correct url code to get canonical url
Before this commit, we would compare a lang `code` (used in context) and a lang `url_code`. For languages where those 2 are differents, the `if` condition would always be falsy, making the canonical URL impossible to be reached. Technically, this condition is used to get the translated name of records to later construct the canonical URL. Since the canonical URL will be incorrect and unreachable, the whole system to tell search engine/crawler about translation won't work since no `alternate/hreflang`[1] will be set in the DOM. [1] see https://developers.google.com/search/docs/advanced/crawling/localized-versions -------- Technical explanation: - italian language `code` = `it_IT`, `url_code` = `it` - belgian french language `code` = `fr_BE`, `url_code` = `fr_BE` Install those languages on website as secondary languages. Translate blog `Travel` to `Voyager` in french and `Viaggi` in italian. Visiting `/fr_BE/blog/travel-1/post/post-1` will redirect to `/fr_BE/blog/voyager-1/post/post-1` as it should, and the canonical URL will be set to that same URL. Visiting `/it/blog/travel-1/post/post-1` will redirect to `/it/blog/voyager-1/post/post-1` as it should, but the canonical URL will be set to `/it/blog/travel-1/post/post-1`. opw-2486918 closes odoo/odoo#69867 X-original-commit: 413357e0f4538ad441184d1d8b4c9a49fc18a5d9 Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
Diffstat (limited to 'addons/website/models')
-rw-r--r--addons/website/models/website.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/website/models/website.py b/addons/website/models/website.py
index abf54ff5129..9a87b1ccef8 100644
--- a/addons/website/models/website.py
+++ b/addons/website/models/website.py
@@ -971,7 +971,7 @@ class Website(models.Model):
for key, val in list(arguments.items()):
if isinstance(val, models.BaseModel):
if val.env.context.get('lang') != lang.code:
- arguments[key] = val.with_context(lang=lang.url_code)
+ arguments[key] = val.with_context(lang=lang.code)
path = router.build(request.endpoint, arguments)
else:
# The build method returns a quoted URL so convert in this case for consistency.