Odoo is a multi-user system, and we would like the to-do tasks to be private to each user. Fortunately for us, Odoo also supports row-level access rules. In the Technical menu they can be found in the Record Rules option, alongside the Access Control List.
Record rules are defined in the ir.rule
model. As usual, we need a distinctive name. We also need the model they operate on and the domain to force access restriction. The domain filter uses the same domain syntax mentioned before, and used across Odoo.
Finally, rules may be either global (the global
field is set to True
) or only for particular security groups. In our case, it could perfectly be a global rule, but to illustrate the most common case, we will make it a group-specific rule, applying only to the employees group.
We should create a security/todo_access_rules.xml
file with this content:
<?xml version="1.0" encoding="utf-8"?> <openerp> <data noupdate="1"> <record id="todo_task_user_rule...