[FIX] base: user.share recomputation
When saving the settings, we perform a `write` on the groups and implied groups. This will trigger a recomputation of the fields `share` on `res.users` and `partner_share` on `res.partner`. On a database with many users, this can lead to a non-negligible time spent in these methods. opw-1830145
This commit is contained in:
committed by
Nicolas Martinelli
parent
691b1f6fa4
commit
6eefb7fb39
@@ -531,12 +531,14 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
|
||||
IrValues.set_default(model, field, value)
|
||||
|
||||
# group fields: modify group / implied groups
|
||||
for name, groups, implied_group in classified['group']:
|
||||
if self[name]:
|
||||
groups.write({'implied_ids': [(4, implied_group.id)]})
|
||||
else:
|
||||
groups.write({'implied_ids': [(3, implied_group.id)]})
|
||||
implied_group.write({'users': [(3, user.id) for user in groups.mapped('users')]})
|
||||
with self.env.norecompute():
|
||||
for name, groups, implied_group in classified['group']:
|
||||
if self[name]:
|
||||
groups.write({'implied_ids': [(4, implied_group.id)]})
|
||||
else:
|
||||
groups.write({'implied_ids': [(3, implied_group.id)]})
|
||||
implied_group.write({'users': [(3, user.id) for user in groups.mapped('users')]})
|
||||
self.recompute()
|
||||
|
||||
# other fields: execute all methods that start with 'set_'
|
||||
for method in dir(self):
|
||||
|
||||
Reference in New Issue
Block a user