When a company has a dozen or several dozen users, a question quickly arises: who should see which data? A salesperson doesn't need to see a colleague's orders from another team, and an employee at branch A shouldn't browse the documents of branch B. In Odoo, this is handled by record rules, which control access to individual records. In this article, we explain how they work, how to configure them, and which mistakes to avoid.
Want to see what permission management looks like in practice? Try Odoo for free and test the rules on your own data.
What are record rules in Odoo?
Record rules (technical model ir.rule) are rules that filter the records a user can access. Each rule is based on a domain, a condition that defines which records are allowed. For example, a rule with the domain [('user_id', '=', user.id)] lets users see only the documents where they are set as the responsible person. Rules work at the ORM level, so they affect lists, searches, reports, and related records, not just views in the interface.
It is worth keeping in mind the difference between two levels of security:
- Access rights – define whether a user can read, edit, create, or delete records of a given model at all (e.g., sales orders).
- Record rules – narrow those permissions down to specific records, e.g., only the user's own records or only those from a given company.
Odoo first checks access rights to the model and only then applies record-level rules. If a user doesn't have read access to the model, no rule will change that. You can read more about the fundamentals of the permission system in the article Odoo Roles and Access Rights – Complete Guide.
How Odoo combines rules: global and group rules
The most important thing when configuring rules is understanding how the system combines multiple rules at once. It depends on whether a rule is assigned to groups.
Global rules
A rule with no assigned groups is global and applies to all users. All global rules are combined with the AND operator, so a record must satisfy every one of them. A typical example is the multi-company rule, which limits data to the companies selected by the user in the company switcher.
Group rules
A rule assigned to one or more groups applies only to members of those groups, including those who belong to them indirectly through inherited permissions. If a user belongs to several groups with rules for the same model, their domains are combined with the OR operator. It is enough for a record to satisfy one of them. This is why a group with broader permissions (e.g., “All Documents”) expands access instead of restricting it. If a user doesn't belong to any of the groups for which rules are defined, group rules don't apply to them, and they are subject only to global rules.
The final result
The set of global rules and the result of combining group rules are ultimately combined with the AND operator. A record is visible only if it passes both stages. Also keep in mind that record rules are not applied to the superuser (the technical system user) or to code executed with sudo(). A regular administrator account with settings access rights is subject to the rules just like any other user.
How to configure record rules step by step
You will find the rules in the technical menu, so first activate developer mode.
- Enable developer mode (Settings → Developer Tools → Activate the developer mode, or add the
?debug=1parameter to the URL). - Go to Settings → Technical → Security → Record Rules.
- Click New and give the rule a clear name.
- Select the model the rule applies to, e.g., Sales Order.
- Define the domain, which is the condition that filters records.
- Specify the groups for which the rule should apply. An empty field means a global rule.
- Check the operations the rule applies to: read, write, create, delete. All are selected by default, and unchecking some means the rule does not cover them.
- Save and test how it works using a test user account.
Configuring rules, especially in an environment with multiple companies and complex team structures, can be complicated and mistakes are easy to make. If you want to be sure that data access is set up correctly, contact our team.
Examples of domains in record rules
Several context variables can be used in domains. The most commonly used are user (the current user), company_id (the currently active company), and company_ids (the list of companies selected in the company switcher, not all companies the user has access to).
- Only own documents:
[('user_id', '=', user.id)] - Own and unassigned:
['|', ('user_id', '=', user.id), ('user_id', '=', False)] - Data of selected companies (handling an empty company field):
['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] - The user's sales team:
[('team_id', '=', user.sale_team_id.id)]
Be careful with records that have an empty company field. If the domain doesn't account for the False value, such records may disappear from view even though they should be accessible.
Want to see how rules behave in practice? Create a free Odoo database and test different access scenarios using accounts with different groups.
Record rules and user groups
Record rules work best in combination with well-designed groups. First take care of the role structure, and only then of detailed filters. The following guide will help with that: How to Set Up User Groups in Odoo: Step-by-Step Guide. If you are just adding new people to the system, take a look at the post How to Create New Users in Odoo: Step-by-Step Guide. You will also find a practical look at limiting data visibility in the article How to Restrict Access to Specific Records in Odoo.
The most common configuration mistakes
- Too many global rules. They are combined with the AND operator, so each additional one further narrows visibility for everyone.
- Not testing with a regular user account. An administrator account usually has broad groups (e.g., “All Documents”) that expand access through the OR operator, so its view doesn't reflect what other users will see.
- Overlooking operations. A rule set only for read won't restrict write or delete if you don't select the appropriate options.
- Modifying standard rules. Instead of changing the rules shipped with modules, it is better to add your own and take them into account during updates.
- Incorrect domains. A typo in a field name or missing handling of empty values can block access to entire lists.
- Overly complex domains. Complex conditions, especially on related fields, are appended to every query and can slow down performance on large datasets.
FAQ – Frequently asked questions
Do record rules apply to the administrator?
Only the superuser (the technical system user) and code executed with sudo() bypass them. A regular administrator account is subject to the rules just like any other user, if the rules apply to its groups. That's why it is worth running tests on accounts with typical permissions.
What is the difference between an access right and a record rule?
An access right determines whether a user can perform operations on the entire model. A record rule selects which specific records of that model are available to the user. Both mechanisms work together.
What happens when a user belongs to several groups with different rules?
Group rules for the same model are combined with the OR operator, so the user gains access to the union of records allowed by each group. Global rules still apply on top of that and restrict the result.
Summary
Record rules are a powerful tool for controlling data access in Odoo. They let you define precisely who can see and modify individual records, and understanding how global and group rules are combined helps you avoid most permission problems. A well-designed rule system protects sensitive information, keeps team work organized, and makes it easier to comply with your company's internal policies.
Need help with permissions in Odoo?
The KK Innovations team will help you design your role structure, configure access rules, and implement Odoo tailored to your organization. Write to us, and we will prepare a custom-made solution.