Hello,
I have a model with records that each have an employee associated with it.
What I want is two views,
one for a normal user where they can only see the records associated with themselves ;
and another administration view where an admin can see every record of that model.
I’ve been able to do mostly that with an ir.rule restricting user from viewing only records where the employee is in the context.
The problem is that the admin can’t get the normal view because they have all the rights, but I want the admin to also have a view where only their records are displayed.
I tried putting a domain on one of the act_window without any success, since I don’t have the employee in the context. Maybe there is a way to get the employee in an action domain but I’m a bit stuck trying right now.
You do not need two views. Using access rules can limit the records shown for each user in a single view. This is because acess rules apply to all records in the system, no mather what view you are using.
You just need to create a new rule that grants access to all rules and link that rule to a group. All users of the group will be allowed to see all the records of the model.
I will recomend having a look at the rules for employee access defined on timesheet lines:
Please note that one rule has the default flag set so it is applied to all users that does not have any other for its group. This is the key point to implement what you are looking for.
I may have a bit overcomplicated what I’m doing. If the admin wants to only see their records they can just filter it, it wouldn’t be very useful to have two views in this context.