Skip to content

Commit

Permalink
[IMP] ir_config_parameter_multi_company: Improved company_id retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoC0 committed Jan 20, 2025
1 parent 5c0a6cf commit 3e662c1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ir_config_parameter_multi_company/models/ir_config_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ class IrConfigMultiCompany(models.Model):

@api.model
def _get_param(self, key):
company_id = self.env.company.id
if not self.env.context.get("allowed_company_ids"):
# We should do this if env is not ready yet or when it fails to get the
# current user. Specifically when installing modules that are trying to
# add new fields in res_users.
query = """
SELECT company_id FROM res_users
WHERE id = %s
"""
self.env.cr.execute(query, (self.env.uid,))
company_id = self.env.cr.fetchone()[0]
else:
company_id = self.env.company.id

if self.env.context.get("force_config_parameter_company"):
company_id = self.env.context["force_config_parameter_company"].id
if company_id:
Expand Down

0 comments on commit 3e662c1

Please sign in to comment.