Odoo Help

Welcome!

This community 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.

0

How to make a field invisible only on create

By
Uillino
on 7/30/15, 11:07 AM 603 views

I have this field:

<field name="write_date" />  

This is one of the reserved fields of Odoo. In this way, I can see when an input as been updated.

There is a problem: who create the input can select date and hour, even if the actual date written in the database is not alterable.

I would like to make this field invisible only when user create a new input. Using:

invisible=1

make this field always invisible. There is a way to make it visible when I list my input?

2

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 7/30/15, 12:01 PM

I think you do not need to change this field interactively later, i.e. in edit mode, so I think it is sufficient to make it readonly by setting readonly="1", this will resolve your issue

if you prefer to make it invisible in the create time then I think you have to inherit the view and add the following line in your xml inherited view

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

or put 'False' in place of 'None'

Try it and feed me back


1
Dr Obx
On 7/30/15, 5:56 PM

IMHO 'readonly="1"' should be OK

However write_date keeps date when record was created/updated. If you want have date when record was created you should use create_date instead.

Anyway, if you use readonly="1" it will be invisible whilst record is created, once record is saved it will be displayed.

0
Uillino
On 7/31/15, 4:43 AM

I've done with the following code:

&lt;field name="write_date" attrs="{'invisible': [('write_date', '=', False)]}"/> 

Thank you very much!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/30/15, 11:07 AM
Seen: 603 times
Last updated: 7/31/15, 7:47 AM