diff --git a/company_default_partner_pricelist/models/res_company.py b/company_default_partner_pricelist/models/res_company.py index 89f4b96e74d..e48ea55742d 100644 --- a/company_default_partner_pricelist/models/res_company.py +++ b/company_default_partner_pricelist/models/res_company.py @@ -6,7 +6,7 @@ class ResCompany(models.Model): _inherit = "res.company" - default_property_product_pricelist = fields.Many2one( + default_property_product_pricelist_id = fields.Many2one( "product.pricelist", string="Default Account Pricelist", help="Default pricelist for this company for new partners.", @@ -14,12 +14,12 @@ class ResCompany(models.Model): def _update_partner_pricelist_generic_property(self): self.ensure_one() - default_property_pp = self.default_property_product_pricelist - ir_property = self.env["ir.property"] + default_property_pp = self.default_property_product_pricelist_id + ir_property_obj = self.env["ir.property"].sudo() field = self.env["ir.model.fields"]._get( "res.partner", "property_product_pricelist" ) - ppty = ir_property.sudo().search( + ppty = ir_property_obj.sudo().search( [ ("name", "=", "property_product_pricelist"), ("company_id", "=", self.id), @@ -36,7 +36,7 @@ def _update_partner_pricelist_generic_property(self): {"value_reference": "product.pricelist,%s" % default_property_pp.id} ) elif default_property_pp: - ir_property.sudo().create( + ir_property_obj.sudo().create( { "name": "property_product_pricelist", "value_reference": "product.pricelist,%s" % default_property_pp.id, @@ -47,13 +47,13 @@ def _update_partner_pricelist_generic_property(self): def create(self, vals): res = super(ResCompany, self).create(vals) - if "default_property_product_pricelist" in vals: + if "default_property_product_pricelist_id" in vals: res._update_partner_pricelist_generic_property() return res def write(self, vals): res = super(ResCompany, self).write(vals) - if "default_property_product_pricelist" in vals: + if "default_property_product_pricelist_id" in vals: for rec in self: rec._update_partner_pricelist_generic_property() return res diff --git a/company_default_partner_pricelist/tests/test_company_default_partner_pricelist.py b/company_default_partner_pricelist/tests/test_company_default_partner_pricelist.py index a20d3995024..f4ecdfecf0a 100644 --- a/company_default_partner_pricelist/tests/test_company_default_partner_pricelist.py +++ b/company_default_partner_pricelist/tests/test_company_default_partner_pricelist.py @@ -25,15 +25,15 @@ def test_company_default_partner_pricelist(self): self.assertEqual(self.partner.property_product_pricelist, self.base_pricelist) # When the default is changed for the active company, the pricelist of # the partner is the one assigned to the current company - self.env.company.default_property_product_pricelist = self.pricelist_2 + self.env.company.default_property_product_pricelist_id = self.pricelist_2 self.partner.invalidate_recordset() self.assertEqual(self.partner.property_product_pricelist, self.pricelist_2) - self.env.company.default_property_product_pricelist = self.pricelist_3 + self.env.company.default_property_product_pricelist_id = self.pricelist_3 self.partner.invalidate_recordset() self.assertEqual(self.partner.property_product_pricelist, self.pricelist_3) - self.env.company.default_property_product_pricelist = False + self.env.company.default_property_product_pricelist_id = False self.partner.invalidate_recordset() self.assertEqual(self.partner.property_product_pricelist, self.base_pricelist)