Odoo Help

1

Domain one2many field?

By
Prakash
on 2/19/13, 8:55 AM 4,923 views

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?

Andreas Brueckl
on 2/19/13, 9:16 AM

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

Camptocamp SA
on 2/19/13, 1:29 PM
0
shameem@iWesabe
On 8/3/17, 9:08 AM

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. 


0
Prakash
On 2/20/13, 1:12 AM

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)]")

Prakash
on 2/20/13, 4:14 AM

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

Camptocamp SA
on 2/20/13, 6:03 AM
0

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)]")

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.

Register

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)

Stats

Asked: 2/19/13, 8:55 AM
Seen: 4923 times
Last updated: 8/3/17, 9:08 AM