diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-02-09 09:35:54 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-02-09 09:35:54 +0100 |
| commit | fda65c7c69566e50a60b5f6d3ca7f213fedc3ec8 (patch) | |
| tree | ba1ba1d8f1fb6705a866f16cb6c251a7780e6299 /addons/web/controllers/main.py | |
| parent | 0e2e9ddd78be24d65ab37424478c994053e5457d (diff) | |
[FIX] menus handling in case user has no menu_id
also add comments to explain some strange-looking code's behavior
bzr revid: xmo@openerp.com-20120209083554-2b8d8qlzz8y9fhan
Diffstat (limited to 'addons/web/controllers/main.py')
| -rw-r--r-- | addons/web/controllers/main.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 3956bb3f891..e81a4459de5 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -694,20 +694,21 @@ class Menu(openerpweb.Controller): # If a menu action is defined use its domain to get the root menu items user_menu_id = s.model('res.users').read([s._uid], ['menu_id'], context)[0]['menu_id'] if user_menu_id: - user_menu_domain = s.model('ir.actions.act_window').read([user_menu_id[0]], ['domain'], context)[0]['domain'] - user_menu_domain = ast.literal_eval(user_menu_domain) - root_menu_ids = Menus.search(user_menu_domain, 0, False, False, context) - menu_items = Menus.read(root_menu_ids, ['name', 'sequence', 'parent_id'], context) - menu_root = {'id': -2, 'name': 'root', 'parent_id': [-1, ''], 'children' : menu_items} - menu_roots = [menu_root] + menu_items + menu_domain = s.model('ir.actions.act_window').read([user_menu_id[0]], ['domain'], context)[0]['domain'] + menu_domain = ast.literal_eval(menu_domain) else: - menu_roots = [{'id': False, 'name': 'root', 'parent_id': [-1, '']}] - + menu_domain = [('parent_id', '=', False)] + root_menu_ids = Menus.search(menu_domain, 0, False, False, context) + menu_roots = Menus.read(root_menu_ids, ['name', 'sequence', 'parent_id'], 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'], 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. menu_items.extend(menu_roots) # make a tree using parent_id |
