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-29 11:41:32 +0000
+++ addons/web/controllers/main.py 2012-11-29 15:15:36 +0000
@@ -924,6 +924,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)
@@ -961,7 +965,7 @@
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,24 @@
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)
+ """
+ Menus = req.session.model('ir.ui.menu')
+
+ if menu_ids == False:
+ menu_ids = Menus.search([], context=req.context)
+ # TDE FIXME: set needaction_enabled column to store, to enable this more limited search
+ # 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',
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js 2012-11-29 11:41:32 +0000
+++ addons/web/static/src/js/chrome.js 2012-11-29 15:15:36 +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-11-26 10:54:50 +0000
+++ addons/web/tests/test_menu.py 2012-11-29 15:15:36 +0000
@@ -42,7 +42,7 @@
[], 0, False, False, self.request.context)
self.MockMenus.read.assert_called_with(
[], ['name', 'sequence', 'parent_id',
- 'action', 'needaction_enabled', 'needaction_counter'],
+ 'action', 'needaction_enabled'],
self.request.context)
self.assertListEqual(
@@ -61,7 +61,7 @@
self.MockMenus.read.assert_called_with(
[1, 2, 3], ['name', 'sequence', 'parent_id',
- 'action', 'needaction_enabled', 'needaction_counter'],
+ 'action', 'needaction_enabled'],
self.request.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