Odoo Help

Welcome!

This community 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.

0

How to use domain to filter user based on department?

By
Johny Levy
on 10/21/15, 2:15 AM 619 views

Hi everyone,


Consider the following situation: 

User1 and User2 in Department A

User3 and User4 in Department B


I'm using Odoo v8, I set the domain in user_id field to filter the only users in selected department will display.

<field name=department_id"/>

<field name="user_id" domain="[('department_id','=',department_id)]"/>

The problem now is when the department_id field is not selected, there is no users to select in user_id field.


How should I set the domain so that when I choose department, user_id field will display users in that department only and when I not choose any department, user_id field will display all users.


Thanks. 

1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/21/15, 2:56 AM

Hi,

I hope you are working with v8. One option is to make the user_id, a compute field that depends on department_id. So when department_id is empty, the user_id shows all users and onchange department_id, the user_id shows only the users in that department. Since onchange() is default in compute fields on new api.

I able to make it work using onchange method. Thanks a lot Akhil

Johny Levy
on 10/21/15, 5:05 AM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/21/15, 2:15 AM
Seen: 619 times
Last updated: 10/21/15, 5:05 AM