Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 669
priyankarani Avatar asked Jun 24 '15 14:06

priyankarani


People also ask

Can we use filtering in tree view of a One2many field?

I have seen the use of filtering in search view, but not in tree view of a one2many field. Note:this is just an example. I have created a sale order. Here same product comes 2 or 3 times. Then I was thinking for a solution… then came to find out that we can pass the filter condition in one2many fields as we provide in search views.

How to syntax-check your XML?

Syntax-Check Your XML. To help you syntax-check your XML, we have created an XML validator. Try to syntax-check correct XML : Try to syntax-check incorrect XML : Try to syntax-check your own XML : Valid XML Documents. A "well formed" XML document is not the same as a "valid" XML document. XML document must be well formed.

How do I check if an XML document is valid?

HTML browsers are allowed to display HTML documents with errors (like missing end tags). With XML, errors are not allowed. To help you syntax-check your XML, we have created an XML validator. A "well formed" XML document is not the same as a "valid" XML document. A "valid" XML document must be well formed.


1 Answers

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

like image 127
Emipro Technologies Pvt. Ltd. Avatar answered Oct 19 '22 23:10

Emipro Technologies Pvt. Ltd.