Apply groups on already created menu

南楼画角 提交于 2019-12-12 08:49:50

问题


I have developed a new module and in that module I have created a group in .xml file.
Now I want to apply that group in menus which are already created in other menu.
So can I apply groups to those menus?
I don't want to override the menu, I just want to apply groups in already created menus.

Thanks in advance.


回答1:


Adding a group to an existing menu is done via the normal OpenERP record update mechanism. You don't actually have to fully redefine the existing menu record in your module, you just declare a <record> with the same ID, with only a value for 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 the official OpenERP addons, such as the CRM module that makes the top-level Sales menu visible to some extra groups (l.48).




回答2:


Instead of updating record, you can replace menuitem itself,

All you have to do is find menuitem that you want to override then add your code to it. For example, 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 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 it doesn't work then first delete that menu and after that write that menu again including your code. For deleting menu,

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

Hope this is helpful.



来源:https://stackoverflow.com/questions/13450393/apply-groups-on-already-created-menu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!