[FIX] website: _compute_pricelist_id compute on correct website

Before this fix, in case you try to compute the pricelist_id with another
context, the computed value is set to the website with the new context,
and so another cache.

Now with compute for the env from self, and assign the computed value with the
website with ot without another context.

Before this commit, you was unable to add fields pricelist_id or currency_id in
a tree view.

opw-2233122

closes odoo/odoo#50705

X-original-commit: 2f83c5bad94775a8f85e65c129afdcf503995ecb
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Jeremy Kersten
2020-05-05 18:47:13 +00:00
parent e9230a1e94
commit 541205fbcb
+1 -4
View File
@@ -56,12 +56,9 @@ class Website(models.Model):
Pricelist._get_website_pricelists_domain(website.id)
)
@api.depends_context('website_id')
def _compute_pricelist_id(self):
for website in self:
if website._context.get('website_id') != website.id:
website = website.with_context(website_id=website.id)
website.pricelist_id = website.get_current_pricelist()
website.pricelist_id = website.with_context(website_id=website.id).get_current_pricelist()
# This method is cached, must not return records! See also #8795
@tools.ormcache('self.env.uid', 'country_code', 'show_visible', 'website_pl', 'current_pl', 'all_pl', 'partner_pl', 'order_pl')