Odoo Help


How to define a read only field

on 2/7/16, 8:38 AM 841 views

I am trying to define a new field in read only mode, but it is not working:

<field name="sale_margin_percent" groups="base.group_user" attr="{'readonly': True}"/>

what is wrong with above definition? thanks


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 2/7/16, 8:49 AM

you can do readonly="1" without attr... attr is usefull if you want use a domain for conditional value...

If I save the record, should readonly="1" fields be stored into database?

on 2/7/16, 9:27 AM
On 2/8/16, 1:10 AM

You can use functional field for this purpose.

On 2/7/16, 9:32 AM

Using readonly="1" makes the user not being able to edit the field, but it is neither moved to database when you store the record.

Aa the field is updatd by onchange events, I would like to be able to avoid user modifying that field but at the same time moving the value back to database on save.

Any ideas?

You can create a second field. First fiels are updated by onchange and invisible in form. Second fields is a related in readonly. Should works...

Jérémy Kersten (jke)
on 2/7/16, 12:01 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.


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)


Asked: 2/7/16, 8:38 AM
Seen: 841 times
Last updated: 2/8/16, 1:10 AM