[IMP] res.users: enable cache on context_get, used by the _() translation function

When _() fails to find a context lang it looks
up the user language by calling context_get().
During module installation this may happen
thousands of times, and drastically slow down
the installation. Caching context_get calls
is an effective way to work around this,
until we find a better solution.

bzr revid: odo@openerp.com-20121217214700-6r7ju8iiaeowgj8i
This commit is contained in:
Olivier Dony 2012-12-17 22:47:00 +01:00
parent 9f77d2e2f4
commit 9bc690bf17
1 changed files with 2 additions and 0 deletions

View File

@ -303,6 +303,7 @@ class res_users(osv.osv):
for id in ids:
if id in self._uid_cache[db]:
del self._uid_cache[db][id]
self.context_get.clear_cache(self, cr)
return res
@ -337,6 +338,7 @@ class res_users(osv.osv):
default['login'] = _("%s (copy)") % user2copy['login']
return super(res_users, self).copy(cr, uid, id, default, context)
@tools.ormcache(skiparg=2)
def context_get(self, cr, uid, context=None):
user = self.browse(cr, SUPERUSER_ID, uid, context)
result = {}