Skip to content

Commit

Permalink
Merge PR #539 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 4, 2023
2 parents d2a33d2 + 99ba24e commit 4e51fa1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions base_multi_company/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ def _check_company(self, fnames=None):
"""Inject as context the company of the record that is going to be compared
for being taking into account when computing the company of many2one's
relations that links with our multi-company models.
We have to serialize the call to super, but it doesn't matter in terms of
performance, as super also makes a for loop in the records.
"""
company_source_id = False
if self._name == "res.company":
company_source_id = self.id
elif "company_id" in self._fields:
company_source_id = self.company_id.id
self = self.with_context(_check_company_source_id=company_source_id)
return super()._check_company(fnames=fnames)
for record in self:
company_source_id = False
if record._name == "res.company":
company_source_id = self.id
elif "company_id" in record._fields:
company_source_id = record.company_id.id
self = self.with_context(_check_company_source_id=company_source_id)
super()._check_company(fnames=fnames)

0 comments on commit 4e51fa1

Please sign in to comment.