youta
youta

Reputation: 391

Access controls list "Editing Odoo security rules"

I'm trying to modify the access control list of Leave Requests to approve under Leave managements module.

I need to make the Leave Requests to approve menu only accessed by each employee's manager.

ea. if the company has 10 employees under Sales/marketing and 5 employees under IT department. I need the sales manager access his 10 employees' leave requests only and not able to access the rest of company's employees who are not under his authority. To do it, I modified the record rule domain definition of Leaves officer from [(1,'=',1)] to [('employee_id.parent_id,'=',user.id)] but it didn't work. How to fix it?

Upvotes: 1

Views: 1602

Answers (1)

DASADIYA CHAITANYA
DASADIYA CHAITANYA

Reputation: 2892

In Your case basically your are totally pass the wrong domain for the record rules.

You are previously using the domain like

[(1,'=',1)] = > Access the all the model record for that model

[('employee_id.parent_id,'=',user.id)] = > Access the Manager parent_id as current user employee only

But in your are accessing only with the manager user only not to access its related user.

so you must have to add the below domain in your record rules:

['|',('employee_id.user_id','=',user.id),('employee_id.parent_id.user_id','=',user.id)]

Basically the manager its self as employee of the company and employee having to attached with its related user.

first Need to understand the following relation :

1. employee_id :

which is indicate the each leave related with one employee.

2. parent_id :

which is indicate the each employee related with one manager for hr.holidays model w[('employee_id.parent_id,'=',user.id)]particular model.hich is called the leave request

3. user_id :

If you want to access the login to the particular employee then and then you must have to set the related user for each employee form.which is labeled as Related User.

4. user :

Which is indicate the global user name means current user which you are currently logged in.

5.id :

means unique id for each record

In your case how the domain will work ?

first it will check the current logged in user as attached current leave employee related user or not. and then then find the user ids which are having with the same employee attached with the same managers.

It means it will perform the OR operation of SQL Statement for both of the domain.

I hope my answer may helpful for you :)

Upvotes: 1

Related Questions