Odoo Help

Welcome!

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.

0

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

By
vx2008
on 8/11/16, 4:56 AM 186 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?

1

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 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???

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)

vx2008
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!

vx2008
on 8/12/16, 4:51 AM

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

vx2008
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.

vx2008
on 8/12/16, 9:26 AM
2
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;

vx2008
on 8/11/16, 8:49 AM
2

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

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"/>"?

vx2008
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.

e.g.

<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。

vx2008
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.

vx2008
on 8/12/16, 9:28 AM

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

2 follower(s)

Stats

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