Apply groups in an already created menu

I developed a new module, and in this module I created a group in an XML file.
Now I want to apply this group to menus that are already created in another menu.
Can I apply groups to these menus?
I don’t want to redefine the menu, I just want to apply groups to the already created menus.

Thanks in advance.

+4
source share
2 answers

Adding a group to an existing menu is done through the usual OpenERP record update mechanism. In fact, you do not need to completely redefine the existing menu entry in your module, you simply declare <record> with the same identifier, only with the groups_id field:

  <record id="original_module.menu_id" model="ir.ui.menu"> <!-- Use the special many2many value syntax to add a child record, and the `ref()` method to resolve the group XML ID --> <field name="groups_id" eval="[(4,ref('my_new_group_id'))]"/> </record> 

You can find similar examples in official OpenERP add-ons, such as the CRM module, which makes the top-level Sales menu visible to some additional groups (l. 48) .

+6
source

Instead of updating the record, you can replace the menuitem itself,

All you have to do is find the menu item that you want to override, and then add your code to it. For example, an already defined menu,

 <menuitem id="menu_example" action="menu_action" name="Example Menu" parent="menu_example_parent" sequence="10"/> 

Now suppose you want to add a group to this menu,

 <menuitem id="existing_module.menu_example" action="existing_module.menu_action" name="Example Menu" parent="existing_module.menu_example_parent" sequence="10" groups="group_example"/> 

If this does not work, first delete this menu and then write down this menu again, including your code. To delete a menu

 <delete model="ir.ui.menu" id="module_name.menu_id" /> 

Hope this is helpful.

0
source

Source: https://habr.com/ru/post/1446900/


All Articles