How to check if one2many field is empty in openerp xml views

priyankarani picture priyankarani · Jun 24, 2015 · Viewed 9.9k times · Source

I'm trying to make some field invisible if another field ( which is one2many ) has no value ( is empty).

I'm trying something like

<field name="reference" invisible="{'line_ids', '=', False}"/>

Also tried

<field name="reference" invisible="{'line_ids', 'in', []}"/>

And finally

<field name="reference" invisible="{'line_ids', '=', None}"/>

Note: line_ids is one2many field

But did not work. Somebody please suggest if some possible way to do this.

Answer

Try following,

<field name="reference" attrs="{'invisible' :[('line_ids', '=', False)]}"/>

This is the behaviour of attrs in odoo, version by version it's differ.

enter image description here