diff options
| author | Thibault Delavallée <tde@openerp.com> | 2012-12-10 14:16:58 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2012-12-10 14:16:58 +0100 |
| commit | 5d2d4dea2cae780f1b42718170b3aedeb2f0df73 (patch) | |
| tree | bb98ec7f4822b39d19590386e36941213a06d3ae /addons/web/controllers | |
| parent | 70f8f99b35c93a880cf15a1f21b7f88aef5a8d36 (diff) | |
| parent | 1ca5e68b1f3ddb440b104c6c47ea35e8d26a1eed (diff) | |
[MERGE] Needaction loading update.
This web revision modifies the way needaction are loaded. Now they are loaded independently of the menus. After having loaded and displayed the various menus, a call to the server is done to avoid a long latency between the login and the display of menus. Needaction counter will be displayed as soon as they are available.
bzr revid: tde@openerp.com-20121210131658-pgy3t9t71f0z2yd5
Diffstat (limited to 'addons/web/controllers')
| -rw-r--r-- | addons/web/controllers/main.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f5710e87218..0e93103d84a 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -924,6 +924,10 @@ class Menu(openerpweb.Controller): return {'data': self.do_load(req)} @openerpweb.jsonrequest + def load_needaction(self, req, menu_ids): + return {'data': self.do_load_needaction(req, menu_ids)} + + @openerpweb.jsonrequest def get_user_roots(self, req): return self.do_get_user_roots(req) @@ -961,7 +965,7 @@ class Menu(openerpweb.Controller): Menus = req.session.model('ir.ui.menu') fields = ['name', 'sequence', 'parent_id', 'action', - 'needaction_enabled', 'needaction_counter'] + 'needaction_enabled'] menu_roots = Menus.read(self.do_get_user_roots(req), fields, req.context) menu_root = { 'id': False, @@ -998,6 +1002,20 @@ class Menu(openerpweb.Controller): return menu_root + def do_load_needaction(self, req, menu_ids=False): + """ Loads needaction counters for all or some specific menu ids. + + :return: needaction data + :rtype: dict(menu_id: {'needaction_enabled': boolean, 'needaction_counter': int}) + """ + Menus = req.session.model('ir.ui.menu') + + if menu_ids == False: + menu_ids = Menus.search([('needaction_enabled', '=', True)], context=req.context) + + menu_needaction_data = Menus.get_needaction_data(menu_ids, req.context) + return menu_needaction_data + @openerpweb.jsonrequest def action(self, req, menu_id): actions = load_actions_from_ir_values(req,'action', 'tree_but_open', |
