Articles>The Unofficial Odoo Field Guide (v12)

The Unofficial Odoo Field Guide (v12)

Reference of field options and field attribute options

Written by
Holden Rehg
Posted on
March 27, 2019

This is a complete reference to all fields that exist in Odoo (as of version 12.0) with the required and optional attributes for each field.


class Many2one(_Relational):
class One2many(_RelationalMulti):
class Many2many(_RelationalMulti):

class Boolean(Field):
class Integer(Field):
class Float(Field):
class Monetary(Field):
class Char(Field):
class Text(Field):
class Html(Field):
class Date(Field):
class Datetime(Field):
class Binary(Field):
class Selection(Field):
        

Many2one

A relationship field defining that Model A has a single reference to Model B. A good example of this, in general, is that Sales Ordersale.order has a partner_id = fields.Many2onereference to res.partner . This means that each sales order has a single Customer/Partner.

One2many

A relationship field defining that Model A has multiple references to Model B and Model B has a corresponding Many2one. A good example of this, in general, is that Sales Order sale.order has aorder_line = fields.One2many reference tosale.order.line and the sale.order.line model has a single reference back to the order via anorder_id = fields.Many2one.

Many2many

A relationship field defining that Model A has multiple references to Model B records and Model B has multiple references to Model A records. A good example of this, in general, is that Sales Ordersale.order has a tag_ids = fields.Many2manyreference to crm.tag.lead. But a single tag can be assigned to many different order records.

Boolean Field

A simple bool type field that stores either aTrue or a False value.

Integer Field

An int4 type field which stores an integer value.

Float Field

A float8 type field which stores a floating point number.

Monetary Field

A special version of a float8 column which automatically displays on the frontend in a certain currency.

Char Field

A char type column field which will stores string values. This is typically used for short strings because it has a default max value of 255 characters.

Text Field

A text type column field which will store long-form string values. This is typically used for longer strings and descriptions because it has no max value for strings.

Html Field

Another text type column that stores long-form strings, except it assumes that the field will be populated with HTML context. This alters the frontend to display formatted HTML context instead of standard utf-8 text.

Selection Field

A selection or enum type column that defines a set of fixed values that the user can select from. A good example of this is thestates field on a sales order. There are many different events hard linked to the sales order states, so we must fix a list of options.

Date Field

A date type column that stores dates without times.

Datetime Field

A datetime type column that stores datetime values.

Binary Field

A bytea type column that stores binary string values. In the case of Odoo it’s base64 encoded binary strings typically.

These fields are ideal for storing documents or images. The frontend of Odoo will then render these via <img/> tags.

Thanks For Reading

I appreciate you taking the time to read any of my articles. If you're looking for more ramblings, take a look at theentire catalog of articles I've written. Or feel free to give me a follow on Twitter, Instagram, or Github to see what else I've got going on. Or see my contact info below if you want to get in touch with me.

web development
open source
odoo
erp
python
Share:

Holden Rehg, Author

Posted March 27, 2019

Other articles you might like