Odoo Help


Restrict Records in Timesheet Activities to User and Employees that are Managed by the User

Damian Bere
on 10/28/15, 5:02 PM 3,038 views


We are using Odoo 9 Contracts Management functionality and need to record timesheets with tasks.  As this is not possible in the default entry form (see this post: https://www.odoo.com/forum/help-1/question/record-activities-time-against-project-tasks-in-odoo-9-timesheets-92869 )  we need to use the Activities view, which shows entries from the Analytic Account Line data model.


The current Activities view shows all records (all activities from all users for all analytic accounts).  

We want to show:

  • The entries related to that user

  • The entries related to employees that user manages, and

  • The entries related to Analytic Accounts / Projects Managed by the User

  • All entries when user is part of a specific Permissions Group (e.g. Human Resources / Manager, etc)

So Far...

  • We are using the record rules to filter what the user can see and are building this up step by step

  • We can successfully filter entries related to the user:  [('user_id','=',user.id)]

  • We tried to also filter where the user was the manager, but failed with many variations of the following:  ['|',('user_id','=',user.id),('user_id.manager_id','=',user.id)]   and  ['|',('user_id','=',user.id),('user_id.employee_ids.parent_id','=',user.id)]  and ['|',('user_id','=',user.id),('user_id.employee_ids.parent_id','child_of',user.id)]  etc etc  

We get exceptions like:  "user_id" not found in "hr.employee" table when using the child_of method, other times it will say no such field/leaf, and yet other times it will not report an error but wont show the expected records either.

Clearly we are just not understanding how to relate to the ORM model, but the documentation we've found doesn't seem to help a great deal (maybe we've missed something though).

Any help or guidance appreciated!


Baiju KS

--Baiju KS--
| 5 5 8
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS
On 10/29/15, 1:21 AM


Everything is correct except manager rule :-

It should be ['|',('parent_id.user_id', '=', user.id),('user_id', '=', user.id)]

the left part cannot be 'user_id.manager_id' or 'user_id.employee_ids.parent_id'  because here user_id is many2one field to res.users and there is no field like .employee_ids and .manager_id in res.users that’s why it throws error.

For selecting manager's user id we have to select manager field and from there the user_id (here manger field is parent_id "many2one field refer to hr.employee itself") :-  'parent_id.user_id' .

Hope this helps.

Thanks for the reply Baiju - it sounds sensible. Unfortunately I can't check this on our system at the moment due to other things going on, but will confirm when I do.

Damian Bere
on 10/30/15, 12:33 PM
On 1/3/18, 1:53 AM


It is late answer. But maybe helps to some others.

I added following domain filter on Activities action.

['&',('is_timesheet', '=', True),'|',('user_id.employee_ids.parent_id.user_id', '=', uid),('user_id', '=', uid)]

This will be show the activities of 

  • related to that user

  • employees related to that current user manages

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/28/15, 5:02 PM
Seen: 3038 times
Last updated: 1/3/18, 2:10 AM