Skip to content

Commit

Permalink
[FIX] company_default_partner_pricelist: field name is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
geomer198 committed Jan 6, 2025
1 parent cffc7b1 commit d1a1f90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions company_default_partner_pricelist/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
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.",
)

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),
Expand All @@ -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,
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d1a1f90

Please sign in to comment.