This question has been flagged
1 Reply
2616 Views

The scenario is like this, in HR module, I set every employee's, now at the purchases module, I'm developing an access rule that filters records based on the manager's subordinates, the manager should see only requests issued by employees that are having this user as their manager.

Please notice that I'm trying to do it through the web administration panel, not through the code.

Here are the models I'm trying to work on:
hr.employee (this contains the manager's id .. another employee)
res.users (this contains the logged in user)
purchase.order (the record I'm filtering on)

Thanks a lot :)

Avatar
Discard
Author

There's a field named "employee_ids" inside the res.users model, is that what you mean?

Best Answer

Hi,

I think you can't achieve it through the interface, since:

  1. You can't get an employee from a user. The point is that there can be a few employees relate to the same user (o2m relation)

  2. Thus in your domain you can't use the leaf like "user_id.employee_id.manager_id.user_id"

Thus, before you prepare a domain, you should state a direct (m2o) relation between user_id & employee_id. Then, prepare a domain rule for purchase orders as for a required user group:

["|",
("user_id.employee_id.manager_id.user_id","=",user.id),  #where employee_id is a new "hr.empliyee" field in "res.users"
("user_id","=",user.id), #besides subordinates observe own
]
Avatar
Discard
Author

There's a field named "employee_ids" inside the res.users model, is that what you mean?

It is a table, you need a single employee. Otherwise, you can't get its manager.