Record rules to restrict employee subordinate hierarchy view ODOO

714 Views Asked by At

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.

Group One:

  • Ned
    • Cat
      • sansa
      • arya

Group Two

  • Robert

    • cersi

      • jammi
      • jofery

When Ned logged in, he should see cat,sansa and arya employee record but not Robert record. Likewise when robert logged in, he should see cersi, jammi, jofery employee record.

The relation is sansa is reporting to cat whereas Cat is reporting to Ned.

What I get is: When I logged in as Ned, I can able to see the Cat record only When I logged in as Cat, I can able to see the Sansa and arya records But When I log in as ned, I want to see his subordinate as well cat subordinate records too.

Thanks in advance

1

There are 1 best solutions below

3
Emipro Technologies Pvt. Ltd. On

There is one important operator is there for such kind of the condition exact like your requirement is : child_of

You need to manage your rules like below.

['|',('parent_id.user_id','child_of',[user.id]),('user_id','=',use‌​r.id)]

or

['|',('parent_id.user_id','child_of',[user.id]),('user_id','child_of',[use‌​r.id])]

I hope this will resolve your issue and fit in your requirement.