Complete Guide to Field Types in Odoo 19
Table of Content
1. Introduction
2. What Are Field Types in Odoo
3. Basic Field Types in Odoo 19
4. Conclusion
Introduction
In Odoo, everything works around data. Whether you're managing operations in the odoo 19 field service module or handling daily tasks, every piece of information is stored using fields. These fields help to organize data in a structured way which makes the system easy to use and manage. During Odoo Implementation , when you define fields properly, your workflows become smoother, more efficient and easier to scale as your business grows.
What Are Field Types in Odoo?
Field types in Odoo define the kind of data you want to store such as text, numbers, dates or relationships between records. They act like rules that tell the system what type of value is allowed in each field. For example, a name field will store text while a price field will store numbers with decimals.
Understanding field types is very important because it directly impacts how your data is managed and displayed across different modules.
When you go through an odoo 19 field types tutorial, you’ll notice that when you choose the right field type it improves data accuracy and reduces errors. It also helps you in automation, reporting and overall system performance.
Start your project on the right foot
A project discovery stage can help you avoid building the wrong product, and we can help you get the discovery stage right. Let’s start with a free call.
Basic Field Types in Odoo 19
Odoo fields are mainly divided into simple field types and relational field types. Each type of field serves a different purpose and helps people to manage data more effectively within the odoo system.
Simple Field Types
Field Type: Boolean
The Boolean field is used to store only two values which are True or False. It is mainly used when you need a simple yes or no option such as marking a record as active or completed.
Parameter:
No specific parameter is required for basic usage. However, it can be customized using common attributes like default values or read-only settings.
Example:
is_active = fields.Boolean(string="Active")
Field Type: Char
The Char field is used to store short text values such as names, titles or codes. It is best for inputs where the length of the text is limited and needs to be controlled.
Parameter:
size – This parameter defines the maximum number of characters allowed in the field. It helps to make sure that the input stays within a specific limit.
Example:
name = fields.Char(string="Name", size=64)
Field Type: Text
The Text field is used to store long text content like descriptions, notes or comments. It helps users to enter large amounts of information without strict length restrictions.
Parameter:
No fixed size parameter is required for this field. It is designed to handle flexible and long-form text input.
Example:
description = fields.Text(string="Description")
Field Type: Integer
The Integer field is used to store whole numbers without any decimal values. If no value is provided, it automatically takes 0 as the default value.
Parameter:
No special parameter is required for basic usage. It can be controlled using standard attributes like required or readonly.
Example:
quantity = fields.Integer(string="Quantity")
Field Type: Float
The Float field is used to store decimal or floating-point numbers which makes it ideal for values that require precision. It is commonly used for data like prices, percentages or measurements where exact numeric accuracy is important.
Parameter:
digits – This parameter defines the precision of the number which includes how many digits appear before and after the decimal point.
Example:
price = fields.Float(string="Price")
Field Type: Date
The Date field is used to store only date values without including time. It is commonly used for tracking events such as service dates or delivery schedules.
Parameter:
No specific parameter is required for basic usage. Default values like the current date can be set if needed.
Example:
date = fields.Date(string="Date")
Field Type: Datetime
The Datetime field stores both date and time in a single field which makes it useful for tracking exact moments. It is widely used for scheduling appointments or setting deadlines.
Parameter:
No mandatory parameter is required for basic usage. It can use built-in functions to set the current date and time.
Example:
start_time = fields.Datetime(string="Start Time")
Field Type: Selection
The Selection field is used to create a dropdown list with predefined options. It helps to make sure that users select only from the available choices.
Parameter:
selection – This defines the list of options that will appear in the dropdown. It helps users to make sure the input is controlled and standardized.
Example:
status = fields.Selection([ ('draft', 'Draft'), ('done', 'Done') ], string="Status")
Field Type: Binary
The Binary field is used to store files such as images, documents or PDFs. The data is stored in an encoded format within the system.
Parameter:
No specific parameter is required for basic usage. It works directly with file upload features in forms.
Example:
file = fields.Binary(string="File")
Field Type: Html
The Html field is used to store formatted content with styling, such as bold text, images and links. It is useful when rich text formatting is required.
Parameter:
No special parameter is required for basic usage. It supports built-in HTML editing tools.
Example:
notes = fields.Html(string="Notes")
Field Type: Monetary
The Monetary field is used to store currency values with proper formatting. It works together with a currency field which helps to make sure that you get accurate financial data representation.
Parameter:
currency_field – This links the monetary value to a specific currency. It helps in correct formatting and rounding of values.
Example:
amount = fields.Monetary(string="Amount", currency_field='currency_id')
Relational Field Types
These are called odoo relational fields because they create connections between different records. Also, they play a key role in structuring real-world business processes.
Field Type: Many2one
The Many2one field creates a relationship where one record is linked to a single record in another model. It is commonly used for linking records like customers or companies.
Parameter:
comodel_name – This defines the model that the field is related to. And It helps to establish a clear connection between records.
Example:
customer_id = fields.Many2one('res.partner', string="Customer")
Field Type: One2many
The One2many field creates a relationship where one record is linked to multiple records in another model. It is mainly used in parent-child relationships.
Parameter:
inverse_name – This defines the field in the related model that links back to the current model. It maintains proper data connection.
Example:
order_line_ids = fields.One2many('sale.order.line', 'order_id')
Field Type: Many2many
The Many2many field creates a relationship where multiple records are linked to multiple records in another model. It is useful for handling complex connections.
Parameter:
comodel_name – This defines the related model involved in the relationship.
Example:
tag_ids = fields.Many2many('product.tag', string="Tags")
Conclusion
Field types are the foundation of how data is structured and managed in Odoo. They are not only define what type of information is stored but also control how different data interact with each other. So if you choose the right field type, it can help you to maintain clean data, improve system performance and reduce errors in daily operations.
In real-world use cases, especially when working with tools like odoo worksheet templates it is important to properly define fields, so that data is captured in a clear and organized way. Similarly, when you are creating custom solutions using odoo studio custom fields it is important to understand field types as it will help you to design forms and workflows that match your business needs perfectly.
Overall, mastering field types gives you better control over your Odoo system. It will make your applications more scalable, user-friendly and efficient.