Access Rights vs Record Rules in Odoo: A Practical Security Guide

Every Odoo implementation eventually reaches the same question:

"Why can this user see that record?"

Or the opposite:

"Why does my salesperson get an Access Error on their own quotation?"

In most cases, the answer lies in one of two security layers that developers often mix up: Access Rights and Record Rules.

They sound similar. They are configured in similar places. But they answer completely different questions.

In this guide, we'll break down how each layer works, how Odoo combines them, and the practical patterns we use in real projects to keep ERP data secure without frustrating users.

Why Security Design Matters in Odoo

An ERP holds a company's most sensitive information — pricing, margins, salaries, customer data, and financial records.

Poorly designed security usually fails in one of two ways:

  • Too open — users see data they should never see (salaries, other branches' margins, other salespeople's pipelines).
  • Too closed — users hit Access Errors in the middle of a workflow, and someone "fixes" it by giving everyone admin rights.

Both are expensive. Getting the model right from the start avoids both.

The Simple Way to Think About It

  • Access Rights answer: "Can this user Read / Write / Create / Delete records of this model at all?"
  • Record Rules answer: "Which specific records of this model can this user work with?"

Access Rights work at the model (table) level. Record Rules work at the record (row) level.

A user must pass both checks to perform an operation.

Access Rights (ir.model.access)

Access Rights grant CRUD permissions on a model to a security group. They are usually defined in security/ir.model.access.csv inside your module.

Example

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_project_expense_user,project.expense.user,model_project_expense,base.group_user,1,1,1,0

access_project_expense_manager,project.expense.manager,model_project_expense,project.group_project_manager,1,1,1,1

What's happening here?

  • All internal users can read, write and create expenses — but cannot delete them.
  • Project managers get full access, including delete.

Key behaviour to remember

  • Access Rights are additive. If any of the user's groups grants a permission, the user has it.
  • A model with no access rule at all is inaccessible to normal users — Odoo logs a warning when you install a module with models missing access rights.
  • A line with an empty group_id applies to everyone, including portal and public users. Use this carefully.

Record Rules (ir.rule)

Once a user is allowed to access a model, Record Rules filter which rows they can see or modify using a domain.

Example: Salespeople see only their own expenses

<record id="project_expense_own_rule" model="ir.rule">

<field name="name">Expense: own records only</field>

<field name="model_id" ref="model_project_expense"/>

<field name="domain_force">[('user_id', '=', user.id)]</field>

<field name="groups" eval="[(4, ref('base.group_user'))]"/>

<field name="perm_read" eval="True"/>

<field name="perm_write" eval="True"/>

<field name="perm_create" eval="True"/>

<field name="perm_unlink" eval="True"/>

</record>


<record id="project_expense_manager_rule" model="ir.rule">

<field name="name">Expense: managers see all</field>

<field name="model_id" ref="model_project_expense"/>

<field name="domain_force">[(1, '=', 1)]</field>

<field name="groups" eval="[(4, ref('project.group_project_manager'))]"/>

</record>

Inside domain_force you can use variables such as user (the current user record), company_id and company_ids (the active companies).

How Odoo Combines Record Rules

This is the part that causes most confusion — and most bugs.

1. Global rules (no group) are combined with AND

Global rules are hard restrictions. Every one of them must be satisfied. The classic example is the multi-company rule:

[('company_id', 'in', company_ids)]

No group membership can bypass a global rule.

2. Group rules are combined with OR

If a user belongs to several groups with rules on the same model, the rules widen access. That's why the manager rule above ([(1, '=', 1)]) works — it adds to the "own records" rule instead of fighting it.

3. The final result

Allowed records = (all global rules) AND (any of the user's group rules)

Rule of thumb: use global rules to restrict, and group rules to grant.

Field-Level Security

Sometimes a user may see the record but not a specific field — for example, cost price or salary.

standard_price = fields.Float(groups='stock.group_stock_manager')

Fields with a groups attribute are hidden from views and blocked at ORM level for users outside those groups. Hiding a field only in the XML view (with invisible) is not security — the data is still accessible through RPC.

sudo(): Powerful, but Use It Carefully

Calling sudo() bypasses both Access Rights and Record Rules.

# Read company-wide configuration the user cannot normally access

settings = self.env['project.expense.config'].sudo().search([], limit=1)

It's the right tool for controlled technical operations — reading configuration, posting a chatter message, creating a system record.

It's the wrong tool for "the user got an Access Error, so let's add sudo()". That simply hides a security design problem and may expose data to people who shouldn't see it.

When you use sudo(), keep its scope small and never return sudo-ed recordsets directly to the user interface.

Checking Access in Code

When writing controllers, wizards or custom methods, check permissions explicitly instead of assuming them. In Odoo 18 and later, recordsets provide a unified API:

# Raises AccessError if the user can't write these records

records.check_access('write')


# Returns True/False instead of raising

if records.has_access('read'):

...

On older versions, the equivalent is the pair check_access_rights() and check_access_rule().

Debugging Access Errors

  • Read the error message carefully. Odoo states whether the block came from access rights (the operation on the model) or from record rules, and usually names the rule.
  • Use "Become Superuser" sparingly — it confirms a permission issue but doesn't show which layer causes it.
  • Check the user's effective groups in Settings → Users, including implied groups.
  • Review Settings → Technical → Security → Record Rules filtered by the model; look for global rules first.
  • Test with a real user account, not the admin. Admin testing hides most security issues until go-live.

Best Practices from Real Implementations

  • Design security around roles (Sales User, Sales Manager, Branch Accountant), not around individual people.
  • Use implied groups so manager roles automatically inherit user permissions.
  • Keep global rules for hard boundaries such as company, branch, or portal ownership.
  • Prefer record rules over view-level hiding, and field groups over invisible attributes.
  • Write automated tests with with_user() to confirm that restricted users really are restricted.
  • Document your security matrix — a simple table of roles vs. models vs. permissions saves hours during audits and upgrades.

Conclusion

Access Rights decide what a user can do with a model. Record Rules decide which records they can do it on. Field groups protect sensitive columns, and sudo() is an escape hatch that should be used deliberately.

When these layers are designed together, Odoo becomes both secure and smooth to use — users see exactly what they need, and nothing more.

At Optura Technologies, we help businesses design role-based security models, audit existing Odoo configurations, and build custom modules that are secure by design.

Need help reviewing your Odoo security setup? Get in touch with our team.

Share this post
Tags
Archive
Add File Attachments to Odoo(19,18,17) Surveys