Odoo Help


Getting the department_id through the user on domain filter

Kevin Carlo Samaniego
on 6/26/13, 7:10 AM 7,978 views

How do I access the department_id through the user.id on a domain filter?

I created a rule with Leave as the object. My goal is to have the user see leaves only from employees of his/her department. I see that an employee is connected to the user by user.id and employee contains the field department_id.

None of the following domain filters worked:





Ghanshyam Prajapati

--Ghanshyam Prajapati--
Ghanshyam Prajapati
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 6/26/13, 7:28 AM

Try Following,

domain = "[('department_id','=',user.id.employee_id.department_id)]" in your xml file.

Hope it work for you.

On what particular XML file do I add it and where is it located? I tried adding the rule on ir_rule.xml under the security folder of the hr_holidays addon but it still doesn't work. Thanks for the answer.

Kevin Carlo Samaniego
on 6/27/13, 3:55 AM

Put this domain on your field, suppose you field is xyz, then add <field name="xyz" domain="[('department_id','=',user.id.employee_id.department_id)]" />

Ghanshyam Prajapati
on 6/27/13, 7:04 AM

I found another way around and it worked. I used this domain filter instead: [('department_id.member_ids','=',user.id)] Thanks again.

Kevin Carlo Samaniego
on 6/30/13, 10:59 PM
Stefan Wailand
On 2/5/14, 2:44 PM

I would say this is the right answer:

<field name="domain_force">[('department_id.member_ids.user_id', 'in', [user.id])]</field>


  • user.id" - in the data model of OpenERP for res_users no way to hr_employee is possible
  • therefore department_id.member_ids will just give back a list with employee_ids
  • in hr.employee the field user_id is available - therefore the path deparment_id.member_ids.user_id is the right way
kenneth mallari
On 6/4/14, 12:04 AM

Hello kevin, nasolve mo ba ung problem mo sa domain filter? hindi ko kc makuha sakin.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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

0 follower(s)


Asked: 6/26/13, 7:10 AM
Seen: 7978 times
Last updated: 3/16/15, 8:10 AM