diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 8068748f72d..42e242b79c3 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1002,8 +1002,8 @@ class Menu(openerpweb.Controller): _cp_path = "/web/menu" @openerpweb.jsonrequest - def load(self, req): - return {'data': self.do_load(req)} + def load(self, req, menu_id=None): + return {'data': self.do_load(req=req, menu_id=menu_id)} @openerpweb.jsonrequest def get_user_roots(self, req): @@ -1031,7 +1031,7 @@ class Menu(openerpweb.Controller): return Menus.search(menu_domain, 0, False, False, context) - def do_load(self, req): + def do_load(self, req, menu_id=None): """ Loads all menu items (all applications and their sub-menus). :param req: A request object, with an OpenERP session attribute @@ -1047,9 +1047,9 @@ class Menu(openerpweb.Controller): # 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) - if req.context and 'default_menu' in req.context and int(req.context['default_menu']): + if menu_id: # for load only one sub menu - menu_ids = Menus.search([['id', 'child_of', req.context['default_menu']]], 0, False, False, context) + menu_ids = Menus.search([['id', 'child_of', menu_id]], 0, False, False, context) else: menu_ids = Menus.search([], 0, False, False, context) menu_items = Menus.read(menu_ids, ['name', 'sequence', 'parent_id', 'action', 'needaction_enabled', 'needaction_counter'], context) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 093368dc6ff..69dafa08c02 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -708,17 +708,9 @@ instance.web.Menu = instance.web.Widget.extend({ this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click); return this.do_reload(); }, - do_reload: function(id) { + do_reload: function() { var self = this; - return this.rpc("/web/menu/load", id ? {'context': {'default_menu': id}} : {}).done(function(r) { - if (id) { - _.each(self.data.data.children, function (val) { - if (val.id == id) { - val.children = _.find(r.data.children, function (r_val) {return r_val.id == id;}).children; - } - }); - var r = self.data; - } + return this.rpc("/web/menu/load", {}).done(function(r) { self.menu_loaded(r); }); },