This question has been flagged
3 Replies
9024 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?

Avatar
Discard
Best Answer

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


Avatar
Discard
Author Best Answer

I've done with the following code:

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

Thank you very much!

Avatar
Discard
Best Answer

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.

Avatar
Discard