diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index ffabe97661b..8068748f72d 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1047,8 +1047,13 @@ 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) - menu_ids = Menus.search([], 0, False, False, context) + if req.context and 'default_menu' in req.context and int(req.context['default_menu']): + # for load only one sub menu + menu_ids = Menus.search([['id', 'child_of', req.context['default_menu']]], 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) + # 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. diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 69dafa08c02..093368dc6ff 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -708,9 +708,17 @@ 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() { + do_reload: function(id) { var self = this; - return this.rpc("/web/menu/load", {}).done(function(r) { + 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; + } self.menu_loaded(r); }); },