diff options
| author | Jeremy Kersten <jke@odoo.com> | 2020-04-17 08:49:41 +0000 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2020-05-08 15:55:08 +0000 |
| commit | 23441987651865293d7847be918d2e7bcdcaf521 (patch) | |
| tree | d405a3e528be4c29490e7f67b3e70ff47d6f9b8c /addons/website_sale/models | |
| parent | 4b9e14719e35090a317dc11b1326969c2cd8e80e (diff) | |
[FIX] website: compute_url should depend of the lang
With this fix, record.with_context(lang='fr').compute_url will have the url
with the slug in french.
Before, it was ignoring the lang since the field was not translatable.
The first compute was stored in cache, and next call just ignore the lang in
the context.
```py
for lang in ['en_US', 'fr_FR']:
print(record.with_context(lang=lang).website_url)
> "/my-name-1"
> "/my-name-1"
```
now
```py
for lang in ['en_US', 'fr_FR']:
print(record.with_context(lang=lang).website_url)
> "/my-name-1"
> "/mon-nom-1"
```
closes odoo/odoo#50951
X-original-commit: 43822adef4ee4c44d10786f28af46df4be260cf5
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website_sale/models')
| -rw-r--r-- | addons/website_sale/models/product.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index 8ab4bed09d3..2976b8195ee 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -406,6 +406,7 @@ class Product(models.Model): website_url = fields.Char('Website URL', compute='_compute_product_website_url', help='The full URL to access the document through the website.') + @api.depends_context('lang') @api.depends('product_tmpl_id.website_url', 'product_template_attribute_value_ids') def _compute_product_website_url(self): for product in self: |
