Create Security Groups in Odoo 16

HARSHAD
February 15, 2023

We have many users in any business management system who have different responsibilities and rights. So, not all functions should be visible to all users. For example, in Odoo Sales Management, the administrator can see all sales, while the salesman can only see his sales. A security group is used to accomplish this. The administrator has a security group and a salesman. We can define record rules based on these groups. In Odoo, we can also specify which security groups are associated with which menus or fields are displayed.

As a first step, I will create two security groups, one for the manager and one for the user. The manager will have full rights, but the user will have limited rights. To add the security groups, I will make an XML file under the security directory.

<record model="ir.module.category" id="module_management">

<field name="name">Overtime</field>

<field name="description">User access level for Overtime module</field>

<field name="sequence">20</field>

</record>
In the user’s form, this will create an Overtime option. To allow users to select their access rights, we need to add the security group.
<record id="overtime_user" modularise.groups">


<field name="name">User</field>


<field name="category_id" ref="module_management"/>

</record>


<record id="overtime_manager" model="res.groups">

<field name="name">Manager</field>

<field name="category_id" ref="module_management"/>

<field name="implied_ids" eval="[(4, ref('overtime_user'))]"/>

</record>

DOWNLOAD ERP

The code creates a security group for both the user and the manager

The user’s group is only created by mentioning the name of the security group and the category_id to which it belongs. We have already created the category above, so we just need to give the category ID. As with the user, we have provided the manager’s name and the category ID, but also the implied_id, which is the user security group’s implied id. The manager will have access to the same rights as the user.

During debug mode, select the Users & Companies menu item to find a menu item called Groups.

The group tab shows all the Odoo security groups that have been created. We can also see the one we just created.

In the user’s settings, we can see the two groups displayed under the category Overtime, and we can choose the users’ security group.

The groups can also be added to the menu item. Sometimes we don’t want to show some of the menu items to users. We can select the group for which we want the menu item to appear by adding groups to the menu item.

Users with the security group will only see the menu item.

Request Your Free Quote

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *