(#116) How to Hide Specific Menus for Individual Users in Odoo 18
Arsalan Yasin
Odoo Functional Consultant | Simplifying ERP Chaos for Global SMEs | 10+ Years of Scaling Systems That Last
The customized ERP system Odoo 18 provides businesses with substantial management capabilities to operate their operations effectively. The business needs security features alongside better user experience by limiting menu access for different types of users in specific operational scenarios. This text provides step-by-step instructions for hiding particular menus for specific users within Odoo 18 by utilizing Access Control Lists (ACLs) and record rules and custom module development procedures.
Why Hide Menus for Specific Users?
The purpose of hiding menus for specific users in Odoo 18 becomes necessary due to multiple essential reasons.
The following section explores different techniques that achieve this task within Odoo 18.
Method 1: Using Access Control Lists (ACLs)
Access Control Lists (ACLs) are a fundamental feature in Odoo that allows you to control access to models and menus based on user groups.
Steps to Restrict Menus Using ACLs
1. Navigate to the Settings Module
2. Create a New User Group
3. Assign Users to the Group
4. Modify ACLs
5. Save and Apply Changes
Method 2: Using Record Rules
Record rules allow you to dynamically filter access to specific records, including menus.
Steps to Hide Menus Using Record Rules
1. Go to Settings > Technical > Record Rules
2. Create a New Record Rule
[('id', 'not in', [menu_id])]
3. Save the Changes
4. Test with a Restricted User
Method 3: Hiding Menus Using XML and User Groups
For advanced customization, you can modify Odoo's XML files to hide menus based on user groups.
Steps to Hide Menus in XML
1. Create a Custom Module
my_module/
├── models/
├── views/
├── security/
├── __init__.py
├── __manifest__.py
2. Define a User Group in Security File
<record id="group_restricted_user" model="res.groups">
<field name="name">Restricted User</field>
</record>
3. Modify the Menu XML File
<menuitem id="menu_specific" name="Hidden Menu" groups="base.group_user, group_restricted_user"/>
4. Update and Restart Odoo
Method 4: Using Python Code in Custom Modules
For developers, using Python code to hide menus dynamically is a powerful approach.
Steps to Implement Dynamic Menu Hiding in Python
1. Open Your Custom Module and Edit models.py
Add the following code:
from odoo import models, api
class HideMenu(models.Model):
_inherit = 'ir.ui.menu'
@api.model
def _filter_visible_menus(self, menu_ids):
user = self.env.user
restricted_menus = [menu_id for menu_id in menu_ids if not user.has_group('my_module.group_restricted_user')]
return restricted_menus
2. Restart Odoo and Test
Testing and Validation
Once you implement any of these methods, it’s important to test the restrictions thoroughly:
Conclusion
For effective user role management in Odoo 18 the process of menu hiding for individual users represents a fundamental step. You can maintain menu access only for approved users through the combination of ACLs and record rules and XML modification and Python scripting. Select the most suitable methodology from among ACLs, record rules and XML modifications and Python scripting based on technological capabilities along with your project specifications.