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.

1

HOW TO PUT A DEFAULT NUMBER ON A FIELD?

By
louie
on 1/18/15, 10:01 PM 1,073 views

WHAT IS THE CODE FOR A DEFAULT VALUE THAT IS NOT EDITED IN OPENERP 7.0? COULD ANYONE PROVIDE ME A CODE FOR THIS? 

5

Atul Arvind

--Atul Arvind--
1854
| 3 3 5
India
--Atul Arvind--

Hello, 

I am odoo Enthusiast/Consultant from Baroda, Gujarat, India. Working with odoo from v5 to v9 and other opensource technology since 4+ years. Having Strong Expertise in

Requirement gathering & Gap Analysis

Odoo Development

Odoo Customization

Odoo Training

Odoo Integration

Server Administration

Odoo Migration

Implementation

I am also active on StackOverflow.

or 


Atul Arvind
On 1/19/15, 1:48 AM

To add a default value in the field you need to define _default model attribute like,

_columns = {
    'field': fields.integer('My integer'),
}

_defaults = {
    'field': 0,
}

_defaults will put the default value to the field while view renders on the browser. 

Model:
'field': fields.char('My integer', readonly=1),

View:
<fields name='field' readonly='1'/>

hope this helps.

2
Anand
On 1/19/15, 12:51 AM

To put a default value use

_defaults={

                   x:10

                  }

to make a field readonly use

x=fields.integer('x',readonly=True)

1
louie
On 1/19/15, 1:40 AM

read only is still editable once you click on the field or change the number

cant get u...

Anand
on 1/19/15, 1:47 AM

have you updated the module?

Atul Arvind
on 1/19/15, 4:26 AM

i mean, if you gonna use read only code you can still edit or change the number once you click on that specific field right?

louie
on 1/19/15, 4:55 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

1 follower(s)

Stats

Asked: 1/18/15, 10:01 PM
Seen: 1073 times
Last updated: 3/28/15, 3:13 AM