2

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.

anon
  • 855
  • 12
  • 22
Palza
  • 642
  • 5
  • 12

2 Answers2

4

The comparaison should be with an empty list:

{'invisible':[('this_field_ids', '=', [])]}
Kenly
  • 24,317
  • 7
  • 44
  • 60
3

To hide One2many field, use this condition inside attrs attribute as follows..

attrs="{'invisible': [('this_field_ids', '=', [(6, False, [])])]}"
Akhil Mathew
  • 1,571
  • 3
  • 34
  • 69