Odoo Help

0

make a many2one field invisible when is empty

By
Giovanny Vizcaya
on 3/17/16, 11:45 PM 1,769 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?

1

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11549
| 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 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 2/27/18, 3:00 AM

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
1

Jignesh Mehta

--Jignesh Mehta--
3110
| 6 5 8
Surat, India
--Jignesh Mehta--

- I have 3+ years of Industry Experience, specializing Odoo Development, Analysis, Customization, Implementation, Integration.
- I have done many Customization modules in Sale, Purchase, Point of Sale, Inventory, CRM and much more. Also Worked in the Odoo Themes like Business Theme or E-Commerce Theme.
- Develop Jewelery Manufacturing process from Scratch. It have more than 10 Department. Develop PDF and Excel reports for this project around 150 per format.

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.

Thanks,

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
0
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.

Register

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)

Stats

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