Understanding Different Types of Fields in Odoo and Their Attributes

A Comprehensive Guide to Field Types and Attributes in Odoo ERP Customization

Muhammad Abdullah Arif
3 min readJun 14, 2024

Odoo, an open-source ERP platform, is highly customizable and allows developers to create various fields to suit the specific needs of a business. Fields in Odoo are the basic components used to store data in models. They define the type of data that can be stored and the behavior of this data within the system. In this blog, we will explore the different types of fields available in Odoo and the attributes that can be set for each type.

Types of Fields in Odoo

Odoo offers a variety of field types, each designed to handle specific kinds of data. Below are the primary field types you can use:

1. Basic Fields

  • Char: A field for storing short text strings.
  • Text: Used for longer text.
  • Integer: For integer numbers.
  • Float: For floating-point numbers.
  • Boolean: A true/false field.
  • Date: For dates.
  • Datetime: For date and time.
  • Binary: For storing binary data like images or files.
  • Selection: A drop-down selection field.

2. Relational Fields

  • Many2one: Creates a many-to-one relationship with another model.
  • One2many: Creates a one-to-many relationship with another model.
  • Many2many: Creates a many-to-many relationship with another model.

3. Special Fields

  • Monetary: A field for monetary values, linked with a currency field.
  • HTML: For HTML content.
  • Reference: A generic reference to any model.

Attributes of Fields in Odoo

Each field type in Odoo comes with a set of attributes that define its behavior and properties. Here are some of the common attributes you can set:

1. Basic Attributes

  • string: The label of the field.
  • required: If True, the field must be filled in.
  • default: A default value for the field.
  • help: Help text for the field.
  • readonly: If True, the field is read-only.
  • index: If True, an index is created on this field.
  • copy: If True, the field value is copied when the record is duplicated.
  • store: If True, the field is stored in the database.
  • translate: If True, the field supports translations.

2. Attributes Specific to Certain Field Types

  • size (Char): The maximum length of the text.
  • digits (Float): Tuple specifying precision (total, decimal).
  • selection (Selection): List of tuples for drop-down values.
  • related (Relational Fields): The path to related fields.
  • ondelete (Relational Fields): Behavior when the referenced record is deleted ('cascade', 'set null', 'restrict').
  • domain (Relational Fields): A domain to filter possible values.

3. Attributes for Relational Fields

  • comodel_name (Many2one, One2many, Many2many): The name of the related model.
  • inverse_name (One2many): The field in the target model that relates back to the source model.
  • relation (Many2many): The name of the table that handles the relation.

Example of Defining Fields in Odoo

Here’s an example of how you might define various fields in an Odoo model:

from odoo import models, fields
class ExampleModel(models.Model):
_name = 'example.model'
_description = 'Example Model'
name = fields.Char(string='Name', required=True)
description = fields.Text(string='Description')
age = fields.Integer(string='Age', default=0)
price = fields.Float(string='Price', digits=(6, 2))
is_active = fields.Boolean(string='Is Active', default=True)
start_date = fields.Date(string='Start Date')
start_datetime = fields.Datetime(string='Start Date and Time')
image = fields.Binary(string='Image')
category = fields.Selection([('a', 'Category A'), ('b', 'Category B')], string='Category')

partner_id = fields.Many2one('res.partner', string='Partner')
order_ids = fields.One2many('sale.order', 'example_id', string='Orders')
tag_ids = fields.Many2many('example.tag', string='Tags')


Fields in Odoo are a fundamental aspect of modeling data within the system. Understanding the different types of fields and their attributes is crucial for customizing Odoo to meet specific business requirements. By leveraging these fields and attributes, developers can create robust and flexible models that cater to a wide range of applications within the Odoo ecosystem.

Click on the link below to discover a wealth of knowledge and explore a variety of engaging topics.

Medium Profile: Muhammad Abdullah Arif — Medium

Stay Up-to-Date with Muhammad Abdullah Arif’s Latest Publications — Subscribe Now! (medium.com)

If you wish to offer your support, kindly click on the link below to treat me to a coffee! ☕️😊


I wish you all the best in your future endeavours.



Muhammad Abdullah Arif

Python developer. The facts are the facts but opinions are my own.