Skip to content

Commit

Permalink
[IMP] joint_buying_base : Add company code in the name of the partner
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Oct 18, 2024
1 parent 28f6e4c commit fa1cac7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions joint_buying_base/migrations/12.0.6.3.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


@openupgrade.migrate(use_env=True)
def migrate(env, version):
ResCompany = env["res.company"].with_context(active_test=False)
companies = ResCompany.search([])
for company in companies:
partner = company.joint_buying_partner_id.with_context(
write_joint_buying_partner=True
)
new_name = company._prepare_joint_buying_partner_vals()["name"]
_logger.info(f"Rename {partner.name} into {new_name} ...")
partner.name = new_name
2 changes: 1 addition & 1 deletion joint_buying_base/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _prepare_joint_buying_partner_vals(self):
self.ensure_one()
icp = self.env["ir.config_parameter"].sudo()
group_name = icp.get_param("joint_buying_base.group_name", "")
suffix = group_name and (" (" + group_name + ")") or ""
suffix = group_name and f" ({self.code} - {group_name})" or f"({self.code})"
vals = {
"name": f"{self.name}{suffix}",
"active": self.active,
Expand Down

0 comments on commit fa1cac7

Please sign in to comment.