[FIX] YAML: `!menuitem` tag handling

The fetched ID was the one of the parent instead of the ID of the imported menu.
This commit is contained in:
Leonardo Rochael Almeida 2015-06-08 03:18:59 +02:00 committed by Martin Trigaux
parent 39745a4290
commit 1005299955
3 changed files with 70 additions and 2 deletions

View File

@ -13,6 +13,7 @@
'auto_install': False,
'test': [
'tests/test_import_reference.yml',
'tests/test_import_menuitem.yml',
]
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,67 @@
- |
YAML Import menuitem scenario:
Check that !menuitem import works with YAML.
- |
Given a standard three level menuitem structure including:
A top level menu item (no parent no action)
-
!menuitem {
id: test_menu_top,
name: "Test Menu Top",
}
- >
An intermediary menu item (parent, but no action)
-
!menuitem {
id: test_menu_sub,
parent: test_menu_top,
name: "Test Menu Sub",
}
- >
A leaf menu item (parent and action)
-
!menuitem {
id: test_menu_action,
name: "Test Menu Action",
parent: test_menu_sub,
action: base.open_module_tree,
}
- >
Another leaf menu item (parent and action) in another menu structure with
dotted parent id
-
!menuitem {
id: test_menu_action_2,
name: "Test Menu Action 2",
parent: base.menu_management,
action: base.open_module_tree,
sequence: 93,
}
- >
Then these menu items should be present and properly configured.
-
!assert { model: ir.ui.menu, id: test_menu_top, string: menu item "top" is properly configured }:
- name == 'Test Menu Top'
- parent_id.name == False
- action == False
-
!assert { model: ir.ui.menu, id: test_menu_sub, string: menu item "sub" is properly configured }:
- name == 'Test Menu Sub'
- parent_id.name == 'Test Menu Top'
- action == False
-
!assert { model: ir.ui.menu, id: test_menu_action, string: menu item "action" is properly configured }:
- name == 'Test Menu Action'
- parent_id.name == 'Test Menu Sub'
- action.name == 'Local Modules'
-
!assert { model: ir.ui.menu, id: test_menu_action_2, string: menu item "action_2" is properly configured }:
- name == 'Test Menu Action 2'
- sequence == 93
- parent_id.name == 'Modules'
- action.name == 'Local Modules'

View File

@ -749,14 +749,14 @@ class YamlInterpreter(object):
noupdate=self.isnoupdate(node), res_id=res and res[0] or False)
if node.id and parent_id:
self.id_map[node.id] = int(parent_id)
self.id_map[node.id] = int(pid)
if node.action and pid:
action_type = node.type or 'act_window'
action_id = self.get_id(node.action)
action = "ir.actions.%s,%d" % (action_type, action_id)
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, 'action', \
'tree_but_open', 'Menuitem', [('ir.ui.menu', int(parent_id))], action, True, True, xml_id=node.id)
'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=node.id)
def process_act_window(self, node):
assert getattr(node, 'id'), "Attribute %s of act_window is empty !" % ('id',)