diff options
| author | Raphael Collet <rco@openerp.com> | 2016-09-02 15:58:39 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2016-09-02 17:28:12 +0200 |
| commit | 9e64f9f9514194d74e166b032add8511182f2677 (patch) | |
| tree | 5086710c04c6b923be18a6d1d97b3f0f3a2a9c4a /odoo/addons/base/tests/test_menu.py | |
| parent | 11812b0b9e82b2b1b9041d8250ce01e7b4a5f7ee (diff) | |
[REF] openerp: move `openerp` to `odoo`
Diffstat (limited to 'odoo/addons/base/tests/test_menu.py')
| -rw-r--r-- | odoo/addons/base/tests/test_menu.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/odoo/addons/base/tests/test_menu.py b/odoo/addons/base/tests/test_menu.py new file mode 100644 index 00000000000..451b63d5f17 --- /dev/null +++ b/odoo/addons/base/tests/test_menu.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests.common import TransactionCase + + +class TestMenu(TransactionCase): + + def test_00_menu_deletion(self): + """Verify that menu deletion works properly when there are child menus, and those + are indeed made orphans""" + Menu = self.env['ir.ui.menu'] + root = Menu.create({'name': 'Test root'}) + child1 = Menu.create({'name': 'Test child 1', 'parent_id': root.id}) + child2 = Menu.create({'name': 'Test child 2', 'parent_id': root.id}) + child21 = Menu.create({'name': 'Test child 2-1', 'parent_id': child2.id}) + all_ids = [root.id, child1.id, child2.id, child21.id] + + # delete and check that direct children are promoted to top-level + # cfr. explanation in menu.unlink() + root.unlink() + + # Generic trick necessary for search() calls to avoid hidden menus + Menu = self.env['ir.ui.menu'].with_context({'ir.ui.menu.full_list': True}) + + remaining = Menu.search([('id', 'in', all_ids)], order="id") + self.assertEqual([child1.id, child2.id, child21.id], remaining.ids) + + orphans = Menu.search([('id', 'in', all_ids), ('parent_id', '=', False)], order="id") + self.assertEqual([child1.id, child2.id], orphans.ids) |
