Tutorial Openerp Basic Code

  • Home
  • About
  • Template
  • Design
  • Blogger
  • Tips Tricks
Home » openerp » source code » Basic Type Fields On Openerp

Basic Type Fields On Openerp

boolean:
A boolean (true, false).
Syntax:
fields.boolean('Field Name' [, Optional Parameters]),
integer:
An integer.
Syntax:
fields.integer('Field Name' [, Optional Parameters]),
float:
A floating point number.
Syntax:
fields.float('Field Name' [, Optional Parameters]),
Note
The optional parameter digits defines the precision and scale of the number. The scale being the number of digits after the decimal point whereas the precision is the total number of significant digits in the number (before and after the decimal point). If the parameter digits is not present, the number will be a double precision floating point number. Warning: these floating-point numbers are inexact (not any value can be converted to its binary representation) and this can lead to rounding errors. You should always use the digits parameter for monetary amounts.
Example:
'rate': fields.float(
    'Relative Change rate',
    digits=(12,6) [,
    Optional Parameters]),
char:
A string of limited length. The required size parameter determines its size.
Syntax:
fields.char(
        'Field Name',
        size=n [,
        Optional Parameters]), # where ''n'' is an integer.
Example:
'city' : fields.char('City Name', size=30, required=True),
text:
A text field with no limit in length.
Syntax:
fields.text('Field Name' [, Optional Parameters]),
date:
A date.
Syntax:
fields.date('Field Name' [, Optional Parameters]),
datetime:
Allows to store a date and the time of day in the same field.
Syntax:
fields.datetime('Field Name' [, Optional Parameters]),
binary:
A binary chain
selection:
A field which allows the user to make a selection between various predefined values.
Syntax:
fields.selection((('n','Unconfirmed'), ('c','Confirmed')),
                   'Field Name' [, Optional Parameters]),
Note
Format of the selection parameter: tuple of tuples of strings of the form:
(('key_or_value', 'string_to_display'), ... )
Note
You can specify a function that will return the tuple. Example
def _get_selection(self, cursor, user_id, context=None):
    return (
       ('choice1', 'This is the choice 1'),
       ('choice2', 'This is the choice 2'))

_columns = {
   'sel' : fields.selection(
       _get_selection,
       'What do you want ?')
}
Example
Using relation fields many2one with selection. In fields definitions add:
...,
'my_field': fields.many2one(
        'mymodule.relation.model',
        'Title',
        selection=_sel_func),
...,
And then define the _sel_func like this (but before the fields definitions):
def _sel_func(self, cr, uid, context=None):
    obj = self.pool.get('mymodule.relation.model')
    ids = obj.search(cr, uid, [])
    res = obj.read(cr, uid, ids, ['name', 'id'], context)
    res = [(r['id'], r['name']) for r in res]
    return res
f
Share
t
Tweet
g+
Share
?
Unknown
18.05

Belum ada komentar untuk "Basic Type Fields On Openerp"

Posting Komentar

Posting Lebih Baru Posting Lama Beranda
Langganan: Posting Komentar (Atom)
Find Us :

Entri Populer

  • Functional Fields On Openerp
    A functional field is a field whose value is calculated by a function (rather than being stored in the database). Parameters: fnct, ar...
  • Relational Types on Openerp
    one2one: A one2one field expresses a one:to:one relation between two objects. It is deprecated. Use many2one instead. Syntax: fields ...
  • Basic Type Fields On Openerp
    boolean: A boolean (true, false). Syntax: fields.boolean('Field Name' [, Optional Parameters]), integer: An integer. S...
  • Create Menu on Openerp
    Menus are records in the ir.ui.menu table. In order to create a new menu entry, you can directly create a record using the record tag. ...
  • Predefined fields in Openerp
    _auto Determines whether a corresponding PostgreSQL table must be generated automatically from the object. Setting _auto to False can be u...
  • Fields Introduction on Openerp
    Here’s the header of the initialization method of the class any field defined in OpenERP inherits (as you can see in server/bin/osv/fields.p...

Mengenai Saya

Unknown
Lihat profil lengkapku
Diberdayakan oleh Blogger.
Copyright 2013 Tutorial Openerp Basic Code - All Rights Reserved
Design by Download software Articel and game free