From 9bc690bf171358eb0828e6d8083d35adffb3ab0f Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 17 Dec 2012 22:47:00 +0100 Subject: [PATCH] [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 --- openerp/addons/base/res/res_users.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index 520f0f14538..ca70724f263 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -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 = {}