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 d48a280
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ msgid "Companies"
msgstr ""

#. module: company_default_partner_pricelist
#: model:ir.model.fields,field_description:company_default_partner_pricelist.field_res_company__default_property_product_pricelist
#: model:ir.model.fields,field_description:company_default_partner_pricelist.field_res_company__default_property_product_pricelist_id
msgid "Default Account Pricelist"
msgstr ""

#. module: company_default_partner_pricelist
#: model:ir.model.fields,help:company_default_partner_pricelist.field_res_company__default_property_product_pricelist
#: model:ir.model.fields,help:company_default_partner_pricelist.field_res_company__default_property_product_pricelist_id
msgid "Default pricelist for this company for new partners."
msgstr ""
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()

Check warning on line 51 in company_default_partner_pricelist/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

company_default_partner_pricelist/models/res_company.py#L51

Added line #L51 was not covered by tests
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
4 changes: 2 additions & 2 deletions company_default_partner_pricelist/views/res_company_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field
name="default_property_product_pricelist"
name="default_property_product_pricelist_id"
domain="[('company_id', 'in', (active_id, False))]"
optional="hide"
/>
Expand All @@ -21,7 +21,7 @@
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field
name="default_property_product_pricelist"
name="default_property_product_pricelist_id"
domain="[('company_id', 'in', (active_id, False))]"
/>
</field>
Expand Down

0 comments on commit d48a280

Please sign in to comment.