Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7191 มุมมอง

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. 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ย. 24
2138
0
มิ.ย. 21
2366
2
พ.ย. 24
2806
1
พ.ค. 24
691
0
พ.ค. 23
2817