Odoo Help

1

Make field readonly on edit but editable on create

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

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

2
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

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: 11/19/14, 4:32 PM
Seen: 1778 times
Last updated: 3/16/15, 8:10 AM