Development Book V17: Groups

The process of creating security groups involves defining sets of users with shared access permissions. All security-related files are typically organized within the security directory, and the path to these files is specified in the __manifest__.py file:

'data': [
    'security/ir.model.access.csv',
    'security/security.xml',
],

To create a security group, an XML file is generated for the group definition. This involves creating a record in the res.groups model. Here's an example:

<record id="school_management_student" model="res.groups">
    <field name="name">Student</field>
    <field name="category_id" ref="school_management.school_management_accesss"/>
    <field name="implied_ids" eval="[(4, ref('group_event_user')), (4, ref('mail.group_mail_template_editor'))]"/>
</record>

In this XML record:

  • id: A unique identifier for the record, distinct for each group in the res.groups table.
  • name: The user-friendly name of the group displayed in the user interface.
  • category_id: Refers to the category to which this group belongs, requiring the creation of a corresponding record in the ir.module.category model.
  • implied_ids: A group that inherits other groups, will get all the other groups' rights on top of their own. The model behind is res. groups.

Creating the module category record:

<record model="ir.module.category" id="school_management_accesss">
    <field name="name">School Management</field>
</record>

Here, the category record includes the name "School Management."

These groups can also be utilized in ir.model.access.csv files as needed. An example of referencing the group in such a file:

id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_test_model,access_test_model,model_test_model,school_management.school_management_student,1,0,0,0

In this ir.model.access.csv file, the group_id/id references the previously created security group.

To access groups from the user interface in Odoo 17, activate the debug mode and navigate to "General Settings -> Users & Companies -> Groups." This section displays all the groups created in the database.

odoo-development

To form new user groups, initiate the process by clicking on the 'New' button, which will prompt the display of a form view, as illustrated below.

odoo-development
whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message