[FIX] share: reduce risk of slowdowns during res.groups changes

Databases with thousands of users would experience
poor performance during any change to a group during
an update/install, caused by the prefetching of
all database users when the browse cache contains
most of the groups in the system.
This commit is contained in:
Olivier Dony 2014-07-23 23:31:36 +02:00 committed by Odoo Online
parent ef53a831c6
commit a09dadd253
1 changed files with 4 additions and 1 deletions

View File

@ -33,7 +33,10 @@ class res_users(osv.osv):
def _get_users_from_group(self, cr, uid, ids, context=None):
result = set()
for group in self.pool['res.groups'].browse(cr, uid, ids, context=context):
groups = self.pool['res.groups'].browse(cr, uid, ids, context=context)
# Clear cache to avoid perf degradation on databases with thousands of users
groups.invalidate_cache()
for group in groups:
result.update(user.id for user in group.users)
return list(result)