From d48a280f10c5468b71a21434e3a8b8c54dde6bda Mon Sep 17 00:00:00 2001 From: Maksim Shurupov Date: Mon, 6 Jan 2025 20:17:31 +0300 Subject: [PATCH] [FIX] company_default_partner_pricelist: field name is updated --- .../i18n/company_default_partner_pricelist.pot | 4 ++-- .../models/res_company.py | 14 +++++++------- .../test_company_default_partner_pricelist.py | 6 +++--- .../views/res_company_views.xml | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/company_default_partner_pricelist/i18n/company_default_partner_pricelist.pot b/company_default_partner_pricelist/i18n/company_default_partner_pricelist.pot index f2709a5b4e1..dbbde0d33b5 100644 --- a/company_default_partner_pricelist/i18n/company_default_partner_pricelist.pot +++ b/company_default_partner_pricelist/i18n/company_default_partner_pricelist.pot @@ -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 "" 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) diff --git a/company_default_partner_pricelist/views/res_company_views.xml b/company_default_partner_pricelist/views/res_company_views.xml index dc8abdee745..117ef66c123 100644 --- a/company_default_partner_pricelist/views/res_company_views.xml +++ b/company_default_partner_pricelist/views/res_company_views.xml @@ -7,7 +7,7 @@ @@ -21,7 +21,7 @@