From 541205fbcb4c0d8e04e45c56cbdfaaeb9e373174 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 5 May 2020 08:09:42 +0000 Subject: [PATCH] [FIX] website: _compute_pricelist_id compute on correct website MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/website_sale/models/website.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/website_sale/models/website.py b/addons/website_sale/models/website.py index deb6e746828..0525f9942fa 100644 --- a/addons/website_sale/models/website.py +++ b/addons/website_sale/models/website.py @@ -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')