how to remove the default value for the fields.integer ?

Asked by Bushair

Hi,
Can anyone tell me the optional parameters values avaialbel for the fields.integer().

when i created an integer using fields.integer ,it is populated with the default value 0.
How to remove this?

Thanks
Bushair

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Borja López Soilán (NeoPolus) (borjals) said :
#1

You may use the "_defaults" dictionary to give the default value for any field.
Each "_defaults" needs either a method name (the method will be called to get the default value, or a one-liner lambda function that just returns the default value. On OpenERP 6.0 you can also just use the value.

class my_example(osv.osv):
     _name = 'my.example'
     _columns = {
         'my_integer': fields.integer('My Integer'),
     }
     _defaults = {
         'my_integer': lambda *a: -1, # Set -1 as the default value for the field "my_integer".
         #'my_integer': -1, # This works on OpenERP 6.0, but not 5.0
     }

And the optional parameters for fields.integer() are these (taken from the technical memento here: http://doc.openerp.com/memento/OpenERP_Technical_Memento_v0.6.4.pdf):

• string: field label (required).
• required: True if mandatory.
• readonly: True if not editable.
• help: help tooltip.
• select: 1 to include in search views and optimize for list filtering (with database index).
• context: dictionary with contextual parameters (for relational fields).
• change_default: True if field should be usable as condition for default values in clients.
• states: dynamic changes to this field's common attributes based on the state field.

Revision history for this message
Numérigraphe (numerigraphe) said :
#2

Bushair, as far as I know integers can't be set to "None" in OpenERP.
I think it could be useful in some situations, feel free to post a wishlist bug report against openobject-server.
Lionel.

Revision history for this message
OpenERP buildbot (openerp-buildbot) said :
#3

On Monday 25 October 2010, you wrote:
> Question #129587 on OpenObject Server changed:
> https://answers.launchpad.net/openobject-server/+question/129587
>
> Numérigraphe proposed the following answer:
> Bushair, as far as I know integers can't be set to "None" in OpenERP.
> I think it could be useful in some situations, feel free to post a wishlist
> bug report against openobject-server. Lionel.

FYI, we have been running a branch with None-support for integers, in
anticipation of any bugs that may appear from such a feature. So far, only
some minor issues have only come up (and fixed).
If this branch is proven, we could consider merging this feature in a *later*
version of OpenERP (not in current 6.0 series, AFAICT).

--
Say NO to spam and viruses. Stop using Microsoft Windows!

Can you help with this problem?

Provide an answer of your own, or ask Bushair for more information if necessary.

To post a message you must log in.