Skip to Content
Menu
This question has been flagged
4 Replies
221 Zobrazenia

Hi guys, I'm trying to restrict (invisible make) certain menu items for a specific user group only. I tried using this code:

<record id="account.menu_finance_entries" model="ir.ui.menu"> <field name="groups_id" eval="[(3, ref('base_accounting_kit.group_account_cashier'))]"/> </record>

...but it's not working. I'm still trying to figure out why. If anyone knows a reliable way to do this, please share. Thanks!

Avatar
Zrušiť
Best Answer

Hi,


Go to Settings > Technical > Menu Item.

Add the user group in the lines as follows,



Or try the code ,


<record id="account.menu_finance_entries" model="ir.ui.menu">

    <field name="groups_id" eval="[Command.link(ref('base_accounting_kit.group_account_cashier'))]"/>

</record>


Related module;- https://apps.odoo.com/apps/modules/19.0/hide_menu_user


Hope it helps

Avatar
Zrušiť
Autor Best Answer

Thanks a lot for your reply 🙏. I just have a small doubt — if I use 6, [...] as you suggested, will that also affect other user groups and hide the menu for them as well?

Avatar
Zrušiť
Best Answer

Hello Uday,



It seems like you're trying to remove a specific user group from a menu item, which is a common requirement for customizing access rights in Odoo. The code snippet you've shared uses the eval attribute with the operation 3 (which stands for removing a record from a many2many field) on groups_id. However, if the menu item still appears, it might be due to one of the following reasons:



  Ensure the module is upgraded

  Verify the user is not assigned to another group that has access

  Check if there's a parent menu item that's visible, making this item accessible


Instead of removing the group, you might want to explicitly set which groups can see the menu by using eval="[(6, 0, [ref('your_module.your_group_id')])]". This replaces the groups with the ones you specify (operation 6 sets a new list of records). Here's how you can adjust your code:



  <record id="account.menu_finance_entries" model="ir.ui.menu">

  <field name="groups_id" eval="[(6, 0, [ref('base_accounting_kit.group_account_cashier')])]" />

  </record>


Remember to upgrade your module after making changes to ensure they take effect. If the issue persists, it might be beneficial to review the user's access rights in detail or consider creating a new group with the specific access rights needed.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

Avatar
Zrušiť
Best Answer

Hello Uday,

<field name="groups_id" eval="[(3, ref('base_accounting_kit.group_account_cashier'))]"/>


In your case, the menu has no groups assigned, so 3, has no effect.

The 3,  works only if the menu already has assigned groups.(it removes the specified group.)

In your case you want to restrict the menu  to a specific group, so you need to overwrite all existing groups using 6, 


<record id="account.menu_finance_entries" model="ir.ui.menu">

    <field name="groups_id" eval="[(6, [ref('base_accounting_kit.group_account_cashier')])]"/></record>

I hope this is helpful for you..

Avatar
Zrušiť

Hello Uday,
You want to hide the menu for others except this user group "group_account_cashier", right?

Related Posts Replies Zobrazenia Aktivita
5
sep 25
1071
1
sep 25
335
1
sep 25
778
1
sep 25
301
3
sep 25
574