Thibault Delavallée (OpenERP) has proposed merging
lp:~openerp-dev/openerp-web/trunk-join-speedup-tde into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-join-speedup-tde/+merge/136623
Perform auto-join and needaction speed 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, an asynchronous 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.
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-join-speedup-tde/+merge/136623
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-join-speedup-tde.
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2012-11-27 10:02:10 +0000
+++ addons/web/controllers/main.py 2012-11-28 11:11:19 +0000
@@ -1035,6 +1035,10 @@
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)
@@ -1071,13 +1075,13 @@
context = req.session.eval_context(req.context)
Menus = req.session.model('ir.ui.menu')
- menu_roots = Menus.read(self.do_get_user_roots(req), ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled', 'needaction_counter'], context)
- menu_root = {'id': False, 'name': 'root', 'parent_id': [-1, ''], 'children' : menu_roots}
+ menu_roots = Menus.read(self.do_get_user_roots(req), ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled'], context)
+ menu_root = {'id': False, 'name': 'root', 'parent_id': [-1, ''], 'children': menu_roots}
# menus are loaded fully unlike a regular tree view, cause there are a
# limited number of items (752 when all 6.1 addons are installed)
menu_ids = Menus.search([], 0, False, False, context)
- menu_items = Menus.read(menu_ids, ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled', 'needaction_counter'], context)
+ menu_items = Menus.read(menu_ids, ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled'], context)
# adds roots at the end of the sequence, so that they will overwrite
# equivalent menu items from full menu read when put into id:item
# mapping, resulting in children being correctly set on the roots.
@@ -1101,6 +1105,25 @@
return menu_root
+ def do_load_needaction(self, req, menu_ids=False):
+ """ Loads needaction counters for all or some specific menu ids.
+
+ :param req: A request object, with an OpenERP session attribute
+ :type req: < session -> OpenERPSession >
+ :return: the menu root
+ :rtype: dict('children': menu_nodes)
+ """
+ context = req.session.eval_context(req.context)
+ Menus = req.session.model('ir.ui.menu')
+
+ if menu_ids == False:
+ menu_ids = Menus.search([], context=context)
+ # TDE FIXME: set needaction_enabled column to store, to enable this more limited search
+ # menu_ids = Menus.search([('needaction_enabled', '=', True)], context=context)
+
+ menu_needaction_data = Menus.get_needaction_data(menu_ids, context)
+ return menu_needaction_data
+
@openerpweb.jsonrequest
def action(self, req, menu_id):
actions = load_actions_from_ir_values(req,'action', 'tree_but_open',
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js 2012-11-28 09:41:31 +0000
+++ addons/web/static/src/js/chrome.js 2012-11-28 11:11:19 +0000
@@ -835,6 +835,21 @@
}
this.trigger('menu_loaded', data);
this.has_been_loaded.resolve();
+ // Now launch the fetch of needaction counters, asynchronous
+ this.rpc("web/menu/load_needaction", {menu_ids: false}).done(function(r) {
+ self.on_needaction_loaded(r);
+ });
+ },
+ on_needaction_loaded: function(data) {
+ var self = this;
+ this.needaction_data = data;
+ _.each(this.needaction_data.data, function (item, menu_id) {
+ var $item = self.$secondary_menus.find('a[data-menu="' + menu_id + '"]');
+ $item.remove('oe_menu_counter');
+ if (item.needaction_counter && item.needaction_counter > 0) {
+ $item.append('<div class="oe_tag oe_tag_dark oe_menu_counter">' + item.needaction_counter + '</div>');
+ }
+ });
},
limit_entries: function() {
var maximum_visible_links = this.maximum_visible_links;
=== modified file 'addons/web/tests/test_menu.py'
--- addons/web/tests/test_menu.py 2012-10-11 11:04:10 +0000
+++ addons/web/tests/test_menu.py 2012-11-28 11:11:19 +0000
@@ -43,7 +43,7 @@
[], 0, False, False, self.request.session.eval_context())
self.MockMenus.read.assert_called_with(
[], ['name', 'sequence', 'parent_id',
- 'action', 'needaction_enabled', 'needaction_counter'],
+ 'action', 'needaction_enabled'],
self.request.session.eval_context())
self.assertListEqual(
@@ -62,7 +62,7 @@
self.MockMenus.read.assert_called_with(
[1, 2, 3], ['name', 'sequence', 'parent_id',
- 'action', 'needaction_enabled', 'needaction_counter'],
+ 'action', 'needaction_enabled'],
self.request.session.eval_context())
self.assertEqual(
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp