[IMP] base: reduce ref calls in users write override.
ref() always trigger a database query to verify record still exists. In frequently used methods, it's best to avoid ref calls if not needed: * either the records should always exist * either the record isn't always needed and the ref can be sometimes avoided. X-original-commit: c1e05da7b71c8274aff00d67f8d1bc7e209fcaab
This commit is contained in:
@@ -1271,8 +1271,10 @@ class UsersView(models.Model):
|
||||
def write(self, values):
|
||||
values = self._remove_reified_groups(values)
|
||||
res = super(UsersView, self).write(values)
|
||||
if 'company_ids' not in values:
|
||||
return res
|
||||
group_multi_company = self.env.ref('base.group_multi_company', False)
|
||||
if group_multi_company and 'company_ids' in values:
|
||||
if group_multi_company:
|
||||
for user in self:
|
||||
if len(user.company_ids) <= 1 and user.id in group_multi_company.users.ids:
|
||||
user.write({'groups_id': [(3, group_multi_company.id)]})
|
||||
|
||||
Reference in New Issue
Block a user