Reputation: 788
I have a One2many
field, and against the attrs I want to put something along the lines of - if this One2many
is blank then hide it.
The One2many
is already auto populated from other objects, so all I need to do is set the invisible to something like...
{'invisible':[('this_field_ids','=',False)]}
There is only one problem... this does not work for a One2many
field.
If it was a boolean
, char
, or Many2one
then it would work, but the One2many
acts differently.
What can I put in the attrs to make this (or in this case, the 'page' that this is within) invisible if it is empty?
I believe that I can make a separate computed field to get the job done, but I wanted to know if I can achieve this without the computed field.
Upvotes: 2
Views: 1950
Reputation: 1659
To hide One2many field, use this condition inside attrs attribute as follows..
attrs="{'invisible': [('this_field_ids', '=', [(6, False, [])])]}"
Upvotes: 3
Reputation: 26678
The comparaison should be with an empty list:
{'invisible':[('this_field_ids', '=', [])]}
Upvotes: 4