Odoo Help


Shall I make nobody edit the records which once are created?

on 8/11/16, 4:56 AM 493 views

I want to get this effect:

once a user create one record, then this record will never been edited by anybody.

shall I and how?


Jusab Sida (jsi)

--Jusab Sida (jsi)--
| 2 2 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 8/11/16, 9:34 AM

What if you just remove "Edit" option from the form???


<form string="My Form" edit="false">


After creating record, if you want like some of field are readonly and some of editable than you can achieve it by attrs.(There are many ways to do this: overriding write method, attrs...)

For ex. if you want after creating a record, Nobody edit 'name' and 'last_name' field then

<field name="id" invisible="1"/>
<field name="name" attrs="{'readonly': [('id','!=',False)]}"/><!--This is readonly after creating record-->
<field name="last_name" attrs="{'readonly': [('id','!=',False)]}"/><!--This is readonly after creating record-->
<field name="age"/><!--This can be editable-->

 Hope this will help you.

thank you for your advice

in the fact , i want to set "edit" ="true" when "My Form" is none(means to never been written) and "edit"="false" when "My Form" is something(means to have been written when created)

on 8/11/16, 7:27 PM

Just put edit="false" in form, it will allow to create but not edit...Thanks

Jusab Sida (jsi)
on 8/12/16, 1:04 AM

So it is

Thank you every much!

on 8/12/16, 4:51 AM

in addtion, shall we just set some fields of this record not be edited?

on 8/12/16, 8:22 AM

see my updated answer..

Jusab Sida (jsi)
on 8/12/16, 8:59 AM

I see; thank you very much.

on 8/12/16, 9:26 AM
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 8/11/16, 8:08 AM


I've two suggestion both of them uses the magic/automatic field 'id'

* in the views you can set your fields readonly when the field 'id' is not False

* make a record rule affecting the write access when the 'id' is not False

Hope they can helps ... 

thank you for your advice;

for example, in .py



in .xml

<field name="TextTest"/>

how shall I modify the code "<field name="TextTest"/>"?

on 8/11/16, 8:52 AM

in xml file, you have to add id field in view, and you have to add attrs on fields to make it readonly.


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

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

Asmita Chavan
on 8/12/16, 7:05 AM

thank you so much; I have tried to do it;

it exactly meet my requirement;

in addition, shall I know what is the mean for ''id'? whether it can do other things?

it is so miraculous。

on 8/12/16, 9:20 AM

I think I know; "id" is the ID of this record which is generated when creating;

Thanks for your time and patience;

thank you very much.

on 8/12/16, 9:28 AM
Shraddha Bagde-Bale
On 8/11/16, 8:29 AM

You can take one boolean field which will be invisible all the time.. Keep default false for that boolean field and in create make the boolean field as True and use this field in attrs for all the fields which you want to make readonly after creating a form.


thank you for your advice;

on 8/11/16, 8:49 AM

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.


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

2 follower(s)


Asked: 8/11/16, 4:56 AM
Seen: 493 times
Last updated: 8/12/16, 4:52 AM