Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] base_multi_company: _check_company multi-record aware #539

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)