This question has been flagged

Hi,
How can i add a field in user settings form and make a menu item visible based on this field.
Thanks in advance.

Avatar
Discard
Best Answer

Hi,

Boolean fields that we see in the users form are the groups in the database, suppose if you need to see a check Box named XYZ in the users form view and if you need to make a menu named ABCD visible only for the users, if the XYZ is ticked, what you have to do is that Create a group named XYZ(either you can do it from ui or from the code), so once the new group is created it will be visible in the users form view.

Now you have to take the menu and add this newly created group to it(either from ui or code).

For creating group from the user interface, you can do it from: Settings -> User & Companies -> Groups(Make sure that the debug mode is activated)

From Code:

<record id="group_xyz" model="res.groups">
<field name="name">XYZ</field>
</record>


To add this group to the menu from UI: Settings -> Technical -> User Interface -> Menu items, search the menu and open it, in the Access rights tab you can see the groups(if there is already some groups, either you can keep it as such or remove it and add the newly created group to it.

From the Code:

<record id="menu_abcd" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('group_xyz'))]"/>
</record>


Thanks

Avatar
Discard
Best Answer

Hello Peter,

You can do a bit of modification in search method of ir.ui.menu

Avatar
Discard