[FIX] website: og:url should be localized

Before this commit, with a website using multiple languages, when sharing
any links with a language other than the original language on Facebook,
the content of Optimize SEO always receives the value of the default
language.

The reason is that `og:url` does not change according to the
language of the website because it's using `http.httprequest.url`.

Note that `http.httprequest.url` doesn't contain the lang part since we
already went through the dispatch's rerouting.
So we need to localize `og:url` to fix this.

Steps to reproduce:
1. Set up 2 different languages for your website (e.g. English, Vietnamese).
 Set the default language for the website to English.
2. Create any page, promote seo page for both languages.
3. Share this link on Facebook with Vietnamese language, see the title
and description on preview are still in English.

closes odoo/odoo#93998

X-original-commit: d47a2e4d08110df380c0060eebb1e9c2924b523e
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Huy Le
2022-06-21 17:58:07 +02:00
committed by Romain Derie
parent 25cb1542b9
commit 414d4f98a1
+1 -1
View File
@@ -56,7 +56,7 @@ class SeoMetadata(models.AbstractModel):
'og:type': 'website',
'og:title': title,
'og:site_name': company.name,
'og:url': request.httprequest.url,
'og:url': url_join(request.httprequest.url_root, url_for(request.httprequest.path)),
'og:image': request.website.image_url(request.website, img_field),
}
# Default meta for Twitter