我开发了一个新模块,在该模块中,我在.xml文件中创建了一个组。
现在我想在已经在其他菜单中创建的菜单中应用该组。
那么我可以在这些菜单上应用群组吗?
我不想覆盖菜单,我只想在已创建的菜单中应用组。
提前致谢。
答案 0 :(得分:9)
通过正常的OpenERP记录更新机制将组添加到现有菜单。您实际上不必完全重新定义模块中的现有菜单记录,只需声明具有相同ID的<record>
,并且只有groups_id
字段的值:
<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>
您可以在官方OpenERP插件中找到类似的示例,例如制作顶级销售菜单visible to some extra groups (l.48)的CRM模块。
答案 1 :(得分:0)
您可以替换menuitem本身,而不是更新记录,
您所要做的就是找到要覆盖的menuitem,然后将代码添加到其中。 例如, 已经定义的菜单,
<menuitem id="menu_example" action="menu_action" name="Example Menu" parent="menu_example_parent" sequence="10"/>
现在假设您要将群组添加到此菜单,
<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"/>
如果它不起作用,则首先删除该菜单,然后再次写入该菜单,包括您的代码。 要删除菜单,
<delete model="ir.ui.menu" id="module_name.menu_id" />
希望这有帮助。