Odoo Help


How to get the readonly feild values in write and create method?

Sairam Bandaru
on 3/30/15, 10:01 AM 1,131 views


I am in situation,Need to save the readonly field values so need to get those values in the write and create method vals

I have the same requirement!

on 3/30/15, 11:03 PM

Hi, Can you please explain your need ,, may be there will be other better solution..?? For Eg: you can use compute field.

Baiju KS
on 3/31/15, 1:54 AM



| 5 3 6
Jakarta, Indonesia
On 3/31/15, 8:59 PM

@Sairam.  Unfortunately readonly fields are implemented INPUT tag with disabled attribute turned on (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input) and thus will not be submitted to the server.

Now, if a field is readonly, usually it won't be changed by the user anyway, so the only possibilities, that I can think, of the value dynamically changed will be due to default or on change mechanism.

If it is due to default (specified in the default_get method or _default attribute of ORM).  You can just create/write without the value of that field.  ORM will automatically get the value from the default mechanism.

If it is due to on change mechanism, you can, by inheriting the write and/or create method, obtain the value of the field from the return of the on change method.

Thanks Ivan. I changed base code in js file to get the readonly values in create or write method

Sairam Bandaru
on 10/13/15, 5:47 AM

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/31/15, 6:06 PM

bad thing, but use a direct database request ...

or set your field invisible and not readonly and add a field function which change its value depending the value of your invisible field.

On 4/2/15, 6:17 PM

Thank you Cyril, works fine.

Sairam Bandaru
On 10/15/15, 3:27 AM


Got the solution by changing the code in base files readonly values will get in create ,write methods so the it will store in database


In view_form.js:

in line: 840:

if (!f.get("readonly")) {

values[f.name] = f.get_value(); }

else { readonly_values[f.name] = f.get_value(); }

values[f.name] = f.get_value();

if (f.get("readonly"))

readonly_values[f.name] = f.get_value();




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: 3/30/15, 10:01 AM
Seen: 1131 times
Last updated: 10/15/15, 3:27 AM