[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) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-07-10 13:46:51 +00:00
parent 8f9e1e40a3
commit 8271be23cf
+1 -1
View File
@@ -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},