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

Using Domain how to filter one2many Fields (job_ids) is equal to [] or job_ids.contact_id is null.

domain="[('job_ids','=',[])]"

domain="[('job_ids.contact_id','=',False)]"

Tried the above 2 code is not working

Thanks

อวตาร
ละทิ้ง

What do you exactly want to do?

The second one cannot work, you are demanding the contact_id of a list of job_ids

คำตอบที่ดีที่สุด

To define a domain in a One2many field you must write it in the python file and the code goes without quotes:

Example: 

'job_ids': fields.One2many(
         ...
         domain=[('contact_id','=',False)]
​)

the quotes were the problem in all previous answers








อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Actual requirement contact name shows only not related partner.

The below domain is not working job_ids is one2many field in res.partner.contact

'contact_id' : fields.many2one('res.partner.contact', 'Contact', domain="[('job_ids','=',[])]"),
อวตาร
ละทิ้ง
ผู้เขียน

Solved domain="[('job_ids','=',False)]")

Okay, I misunderstood your question. I have deleted my answer.

คำตอบที่ดีที่สุด

See example :

display_record is a  boolean field in one2many.

Setting  attrs in all fields.

<tree>
    <field name="field_1" attrs="{'invisible': [('display_record','=',False)]}"/>
    <field name="field_2" attrs="{'invisible': [('display_record','=',False)]}"/>
    <field name="field_3" attrs="{'invisible': [('display_record','=',False)]}"/>
    <field name="field_4" attrs="{'invisible': [('display_record','=',False)]}"/>
    <field name="field_5" attrs="{'invisible': [('display_record','=',False)]}"/>
    <field name="dispaly_record" invisible="1"/>
</tree>

If the value of dispaly_record  is False, the entire row will be invisible. 


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

To filter in many2one, one2many and many2many, you have to directly use the fields of the related object.

For exemple:

'job_ids': fields.on2many(
         ...
         domain="[('contact_id','=',False)]")
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Change your second domain as:

domain="[('job_ids.id.contact_id','=',False)]"


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 24
4208
[Solved] Close window on button press แก้ไขแล้ว
1
ธ.ค. 23
19771
1
ก.ค. 15
6147
2
มี.ค. 15
6648
1
มี.ค. 15
7632