From 8271be23cf2b056263e676c6994e510c72cd3181 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 10 Jul 2019 13:40:21 +0000 Subject: [PATCH] [FIX] product: _inverse_product_pricelist uses wrong company When reading the non stored computed field property_product_pricelist, the force_company set in the context is taken into account. But when writing on property_product_pricelist, the force_company was not taken into account. So it was inconsistent as you could read a record with a force_company in the context and wrote on an other record as the inverse function didn't take the force_company into account. closes #31561 opw:2032024 closes odoo/odoo#34757 Signed-off-by: Simon Goffin (sig) --- addons/product/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/models/res_partner.py b/addons/product/models/res_partner.py index 5eb0e652187..d74be5105ad 100644 --- a/addons/product/models/res_partner.py +++ b/addons/product/models/res_partner.py @@ -34,7 +34,7 @@ class Partner(models.Model): # update at each change country, and so erase old pricelist if self.property_product_pricelist or (actual and default_for_country and default_for_country.id != actual.id): # keep the company of the current user before sudo - self.env['ir.property'].with_context(force_company=self.env.user.company_id.id).sudo().set_multi( + self.env['ir.property'].with_context(force_company=self._context.get('force_company', self.env.user.company_id.id)).sudo().set_multi( 'property_product_pricelist', self._name, {self.id: self.property_product_pricelist or default_for_country.id},