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

readonly option in fields?

By
Tomas Parnarauskas
on 3/22/13, 10:38 AM 10,682 views

Hello, I don't understand how this readonly options works in openerp. For example in a module I create this column:

'number': fields.float('Number', readonly=True)

So when I install module with this column, in OpenERP object that is added it should show that this column is readonly? because in my case id does not. It shows that readonly option is not chosen for that column. Why it is ignoring my option for readonly=True?

2

saad

--saad--
1008
| 5 4 8
Casablanca, Morocco
--saad--
saad
On 3/22/13, 11:22 AM

Check first if there is no readonly='False' for this field in your view xml definition !

2

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 3/22/13, 11:28 AM

If you read your openerp log you can find this:

openerp.osv.fields: required=True is deprecated: making a boolean field `required` has no effect, as NULL values are automatically turned into False. args: {'readonly': True}

Set the readonly in python code, like this:

'number': fields.float('Number', {'readonly': True})

or in a xml, like this:

<field name="number" readonly="1" />

I think the python code should be 'number': fields.float('Number', readonly=True).

Mohammad Alhashash
on 4/17/13, 8:18 AM

In the new version of openerp this syntax is deprecated. The right syntax is the code in the answer.

Francesco OpenCode
on 4/17/13, 8:24 AM

how set field attr to readonly by function.?

priyankahdp
on 4/19/13, 9:42 AM

It's better if you open a new answer for this.

Francesco OpenCode
on 4/19/13, 11:12 AM
1

AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
2060
| 4 5 8
Bronx, United States
--AJ Schrafel Paper Corp--

Exploring OpenERP for business

AJ Schrafel Paper Corp
On 3/22/13, 12:06 PM

That definition is for the column in the database only, not what is displayed to the user via the XML view.

You must include <field name="number" readonly="1" /> in your XML to make it read only to the user.

The proper python code would be 'number': fields.float('Number', {'readonly': True}) but then how will you ever get information into the field via the web interface? This will make the field readonly for every user. Even if you later set the field to readonly="0" in the XML, when you goto save your data, an error will be thrown.

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

0 follower(s)

Stats

Asked: 3/22/13, 10:38 AM
Seen: 10682 times
Last updated: 3/16/15, 8:10 AM