Record rules to restrict employee subordinate hierarchy view
I want to set some record rules to restrict employees to view only their profile and their subordinates profiles. No one else out of a particular employee's subordinate hierarchy should be displayed to him. For example, this is my employee hierarchy.
When Alex logged in, he should be able to see all the employees. When Benjamin logged in, he should be able to see his profile and David's, Edward's, Frank's, Ivan's and Jack's profiles only. When David logged in, he should be able to see his profile only.
I have tried the following record rules on Employee object:
- [('user_id','=',user.id)] Allows to see logged in user's profile only.
- [('parent_id.user_id','=',user.id)] Allows to see immediate subordinates only. That means, when Alex logged in, he can see Benjamin and Charles only, not the in depth hierarchy.
- [('child_ids','child_of', [user.id])] It gives a view of logged in user, his first immediate subordinate, first next level subordinate. That means, when Alex logged in, he can see his profile, Benjamin's profile and David's profile only.
I still couldn't work out a way to satisfy my requirement. Any help would be appreciated.
Thank you very much!