1.找到定义的菜单
下面是mail模块的top菜单,显示在页面左上角的,拿它举例
<menuitem
id="mail.mail_channel_menu_root_chat"
name="Discuss"
action="mail_channel_action_client_chat"
web_icon="mail,static/description/icon.png"
groups="base.group_user"
sequence="1"/>
2.隐藏
有一种方法是直接在groups中写上group,对属于该组的成员可见,'base.group_user'就是对所有人可见了。然后自定义一个新的group,任何user都不属于这个组,然后修改groups等于你定义的group,这样也可以,但是不一定好用~ 需要将子菜单也用同样方法限制,才能完全隐藏top menu。
下面是更简单的规则:
那如果想操作对所有人不可见,可以修改菜单属性
<record id="mail.mail_channel_menu_root_chat" model="ir.ui.menu">
<field name="groups_id" eval="[(3, ref('base.group_user'))]"/>
</record>
id是对应的,3的意思是删除关系,对'base.group_user'是不可见。
换成自定义的group也是同理。
3.eval
- (0, 0, { values}) Link to a new record that needs to be created with the given values dictionary.
- (1, ID, { values }) Update the linked record with id = ID.
- (2, ID) Remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well).
- (3, ID) Cut the link to the linked record with id = ID (delete the relationship between the two objects but does not dete the target object itself).
- (4, ID) Link to existing record with id = ID (adds a relationship).
- (5) Unlink all (like using (3, ID) for all linked records).
- (6, 0, [IDs]) Replace the list of linked IDs(like using (5) then (4,ID) for each ID in the list of IDs).