Odoo Help


Creating a New Field Type Odoo ?

on 2/27/15, 9:14 AM 1,232 views

I want to create a new field type , so is there any documentation on how to create a new field type api for example fields.char or fields.date such that I can begin from it .

I don't think there is any (official) documentation on that, but you should look through the code. Depending on your Odoo version (7 or 8 and up) the field definitions are either on osv.osv or Model class. You could use for example the structure used for char as a starting point. Disclaimer: I have never done this myself and do not know how it is done precisely, but this would be my approach.

Ludo - Neobis
on 2/27/15, 9:39 AM
Jordan Vrtanoski
On 2/27/15, 3:52 PM

You need to start by reading the implementations in the osv.fields module. In nutshell, all fields are inherited from _column. Depending on the nature of the field you are creating, you might need to implement your own "set", "get" and "serach" methods to handle the database interaciton. Here is small example to get you started. You can read more from the sourcecode of fields.py

from openerp.osv import fields, osv
class mynewfield(fields._column):

    _type = 'char'
    def __init__(self, string="unknown", size=None, **args):
        fields._column.__init__(self, string=string, size=size or None, **args)
        # self._symbol_set_char defined to keep the backward compatibility
        self._symbol_f = self._symbol_set_char = lambda x: _symbol_set_char(self, x)
        self._symbol_set = (self._symbol_c, self._symbol_f)
fields.mynewfield = mynewfield

Having saed this, I strongly recommand you to try and reusing some of the existing fields and if you need specialized display in the GUI or you need specilaized GUI editor, you can write a web Widget in JavaScript withouth creating a custom fields in the OSV. There are good tutorials how to create new Widgets and are asy to follow.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/27/15, 9:14 AM
Seen: 1232 times
Last updated: 3/16/15, 8:10 AM