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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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?
What if you just remove "Edit" option from the form???
Like...
<form string="My Form" edit="false">
UPDATED:12-8-16
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)
Just put edit="false" in form, it will allow to create but not edit...Thanks
So it is
Thank you every much!
in addtion, shall we just set some fields of this record not be edited?
see my updated answer..
I see; thank you very much.
Hi,
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
TextTest=fields.Char()
..
in .xml
<field name="TextTest"/>
how shall I modify the code "<field name="TextTest"/>"?
in xml file, you have to add id field in view, and you have to add attrs on fields to make it readonly.
e.g.
<field name="id" invisible="1">
<field name="TextTest" attrs="{'readonly': [('id', '!=', False)]}"/>
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。
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.
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;
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up