Odoo Help


make a many2one field invisible when is empty

Giovanny Vizcaya
on 3/17/16, 11:45 PM 1,569 views


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?


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 2/27/18, 3:00 AM


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
Website: http://www.erpharbor.com
--Jignesh Mehta--

Jignesh Mehta
On 3/18/16, 3:01 AM

Hello Giovanny,

Remove quote from False

Try this :-

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

Hope it works for you.


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

Giovanny Vizcaya
on 3/18/16, 10:40 AM
Jesús Marco
On 2/26/18, 2:46 PM

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.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/17/16, 11:45 PM
Seen: 1569 times
Last updated: 2/27/18, 3:00 AM