This question has been flagged
4 Replies
19302 Views

Greetings

i'm triying to make invisible a one2many field when it hasn't some data in the field... i tried with

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

but that makes it invisible as same way invisible="True".


How can i solve it?

Avatar
Discard
Best Answer

Hi,

Try the following code:

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

This will hide your field when it is filled up and will be visible when it is blank / empty.

Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Avatar
Discard
Best Answer

Hello Giovanny,


Remove quote from False

Try this :-

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


Hope it works for you.

Thanks,

Avatar
Discard
Author

Doesn't work... same problem... i need it visible when create a new employee, and after saving, if field is empty becomes invisible

Best Answer

Hi.

Relation field, like m2o or o2m or m2m, is empty when its value is []. Then, your code should be like this: 

Hope it helps.

Avatar
Discard

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

Best Answer

Maybe you are confused on "when" the attr invisible is going to be executed; you have to have in mind that when the condition is True, then the field WILL BE invisible, that said.... when creating a new employee that field is invisible because 'parent_id' has not retrieve any value from anywhere, to avoid this scenario then you should put 'parent_id' with a True default value.... then after saving the employee, you check the new employee record info and you did not introduce a value on 'parent_id' field, then the value is null which will cause the field to be invisible, because the condition ('parent_id ', '=', False) will be returning TRUE.

Avatar
Discard