Odoo Help


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.


Make field readonly on edit but editable on create

Sandy Carter
on 11/19/14, 4:32 PM 1,139 views

In a form view, what way would you have a field only be editable when the object is crated and not editable afterwards.

Sandy Carter
On 11/19/14, 4:36 PM

An object on create will not have an id. Afterwards, it will always have one.

Taking advantage of this behaviour, the id can be used to set the readonly attribute.

<field name="id" invisible="1"/>

<field name="uneditable_field" attrs="{'readonly': [('id', '!=', False)]}"/>

Well done. I was stuggled with this. I didn't think to add the "id" field as invisible to make it available in the domain. Thanks for sharing! J

Savoir-Faire Linux, Jordi Riera
on 11/19/14, 4:49 PM

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)


Asked: 11/19/14, 4:32 PM
Seen: 1139 times
Last updated: 3/16/15, 8:10 AM