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.
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.
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.
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.
Try following,
<field name="reference" attrs="{'invisible' :[('line_ids', '=', False)]}"/>
This is the behaviour of attrs in odoo, version by version it's differ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With