DEV Community

Cover image for Odoo User Permission and Groups
maisie brooke
maisie brooke

Posted on

Odoo User Permission and Groups

To effectively manage user permissions and groups in Odoo, a technical understanding of its security framework is essential. Odoo uses Access Control Lists (ACLs) and Record Rules to define user access to specific models and records. Additionally, groups are used to categorize users and assign permissions collectively.

Steps to Create User Permissions and Groups in Odoo:
Define a Security Group:
In Odoo, you can define a security group in the XML file. Security groups are used to assign specific permissions to a group of users.

<record id="group_custom_manager" model="res.groups">
    <field name="name">Custom Manager</field>
    <field name="category_id" ref="base.module_category_custom"/>
</record>
Enter fullscreen mode Exit fullscreen mode
  • Assign Access Rights (ACLs): Define access rights using ir.model.access rules. These specify permissions like read, write, create, and delete.
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_custom_model_manager,access_custom_model_manager,model_custom_model,group_custom_manager,1,1,1,1
Enter fullscreen mode Exit fullscreen mode
  • Set Record Rules: Record rules control access to specific records within a model.
<record id="custom_model_rule" model="ir.rule">
    <field name="name">Custom Model Rule</field>
    <field name="model_id" ref="model_custom_model"/>
    <field name="domain_force">[('user_id', '=', user.id)]</field>
    <field name="groups" eval="[(4, ref('group_custom_manager'))]"/>
</record>
Enter fullscreen mode Exit fullscreen mode
  • Apply Groups to Models: You can restrict the visibility of menus or models based on groups.
<menuitem id="menu_custom_manager"
          name="Custom Manager"
          parent="base.menu_administration"
          groups="module_name.group_custom_manager"/>

Enter fullscreen mode Exit fullscreen mode
  • Assign Groups to Users: Assign the newly created group to users via the user form or programmatically:
user = self.env['res.users'].browse(user_id)
group = self.env.ref('module_name.group_custom_manager')
user.groups_id = [(4, group.id)]

Enter fullscreen mode Exit fullscreen mode
  • By leveraging Odoo’s flexible security system, you can customize permissions and create tailored user experiences, ensuring that users access only what they need.

For "odoo development services", you can explore advanced customization, including building and deploying user permission systems tailored to specific business workflows. If you're seeking expert assistance in Odoo development, contact us for professional services

Top comments (0)