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

How to define a read only field

By
E.M.
on 2/7/16, 8:38 AM 382 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

1

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2993
| 3 2 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?

E.M.
on 2/7/16, 9:27 AM
0
Jinesh
On 2/8/16, 1:10 AM

You can use functional field for this purpose.

0
E.M.
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

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

1 follower(s)

Stats

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