summaryrefslogtreecommitdiff
path: root/addons/web_planner/models/web_planner.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2015-09-15 11:56:56 +0200
committerRaphael Collet <rco@openerp.com>2015-09-15 14:34:31 +0200
commit84ade6a8617e38c0afdd156e404f59a943feedca (patch)
treefd8c3c83d6d1f4e082c87b7dceaf26218d8af1b4 /addons/web_planner/models/web_planner.py
parent45d53ec4659681573cbf82c26134a4e0bf6ae0be (diff)
[IMP] web_planner: optimize method `render` of `web.planner`
This method generates many queries on: - `ir.module.module`, to known whether a given module is installed; - `ir.actions.act_window`, to know whether a given action exists. Add a cache for both cases. The number of queries is reduced by 90%.
Diffstat (limited to 'addons/web_planner/models/web_planner.py')
-rw-r--r--addons/web_planner/models/web_planner.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/addons/web_planner/models/web_planner.py b/addons/web_planner/models/web_planner.py
index 2236486c0f1..15e462428c6 100644
--- a/addons/web_planner/models/web_planner.py
+++ b/addons/web_planner/models/web_planner.py
@@ -62,12 +62,11 @@ class Planner(models.Model):
params['model'] = 'ir.module.module'
# setting the module
if module_name:
- module = self.env['ir.module.module'].sudo().search([('name', '=', module_name)], limit=1)
- if module:
- params['id'] = module.id
+ installed = self.env['ir.module.module']._installed()
+ if module_name in installed:
+ params['id'] = installed[module_name]
return "/web#%s" % (urlencode(params),)
@api.model
def is_module_installed(self, module_name=None):
- count = self.env['ir.module.module'].sudo().search_count([('state', '=', 'installed'), ('name', '=', module_name)])
- return bool(count)
+ return module_name in self.env['ir.module.module']._installed()