Skip to Content

Float Field in Odoo: The Complete Guide

A practical guide to the Float field in the Odoo data model, from basic usage to precision control and technical customization
March 6, 2026 by
Float Field in Odoo: The Complete Guide
Dasolo
| No comments yet

Introduction


The Float field is one of the most frequently used field types in Odoo when your data involves decimal numbers. Unit prices, product weights, discount percentages, tax rates, conversion factors in bills of materials - all of these are typically stored as Float fields in the Odoo data model.


At first glance it looks like a simple numeric input. But there are several things worth knowing about how it handles precision, how it behaves in reports and aggregations, and when you should use a different field type instead.


This guide covers what the Float field stores, how it behaves in the Odoo framework, how to create and customize it using Odoo Studio or Python, and real business use cases across Sales, Inventory, and Accounting.

What is the Float Field in Odoo


In the Odoo ORM, the Float field stores decimal numbers. It maps to a double precision column in PostgreSQL, which provides up to 15 significant digits of precision. For most business use cases, that is far more than you need.


From the user perspective, a Float field appears as a numeric input in form views. The number of decimal places shown is controlled by the digits parameter you define on the field. In list views, Float values display with the same precision and are right-aligned by default. In pivot tables and graphs, Float fields participate in aggregations like sum, average, or maximum.


Here is how it looks in a Python model definition:

from odoo import fields, models

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

    custom_margin = fields.Float(
        string='Custom Margin',
        digits=(5, 2),
        default=0.0,
    )

The digits parameter is a tuple. The first number is the total number of significant digits, the second is the number of decimal places. So (5, 2) allows up to five significant digits with two decimal places.

You can also reference a named precision group rather than hardcoding the digits:


price_premium = fields.Float(
    string='Price Premium',
    digits='Product Price',
)

Odoo has several built-in precision groups managed under Settings > Technical > Database Structure > Decimal Accuracy. The main ones include Product Price, Product Unit of Measure, Discount, and Stock Weight. Using precision groups means users can adjust the decimal precision from the interface without any code change.


In Odoo Studio, the Float field is labeled Decimal Number. When created through Studio, it uses the default precision unless you configure it otherwise in the field properties panel. This makes it one of the more accessible Odoo studio fields for business users who need to extend forms without developer support.

How the Field Works


When you define a Float field in Odoo, the framework handles the column creation in the database automatically during module installation or upgrade. No manual SQL or migration scripts are needed.


The digits parameter controls two things at once: how values are displayed in the interface, and how they are rounded before being stored. If you define digits=(6, 2) and a user enters 3.14159, Odoo rounds and stores 3.14. This rounding happens at the ORM level, not just in the display layer.


Key Field Attributes

These are the most important properties you can configure on a Float field in the Odoo framework:

  • digits: A tuple like (6, 2) or a named precision group string. Controls both display and storage precision.
  • required: Makes the field mandatory. A Float field with a value of 0.0 will pass the required check, which may not always be the intended behavior.
  • default: Default value when a new record is created. Setting default=0.0 ensures the field always has a numeric value rather than False.
  • compute: Links a Python method that calculates the field value dynamically. Useful for derived values like margins or conversion results in odoo computed fields.
  • store: When used with compute, saves the computed value to the database so it can be searched, filtered, and grouped.
  • group_operator: Controls how the field is aggregated in pivot and graph views. Common values are 'sum', 'avg', 'min', and 'max'. Float fields default to 'sum'.
  • copy: Controls whether the value is copied when duplicating a record. Defaults to True.

How It Appears in Views

In form views, a Float field renders as a numeric input. The display respects the user locale for decimal separators. In list views, Float values are right-aligned by default. In search views, you can filter by Float values using numeric comparison operators.


You can apply widgets to Float fields in views. The percentage widget, for example, multiplies the stored value by 100 for display and adds a percent sign, which is useful for fields storing values in the 0-1 range. This is a common pattern in Odoo development when working with rates and factors.


Interaction with the Odoo ORM

Reading a Float field gives you a Python float, or False if the field has not been set and no default is defined. Writing to a Float field accepts integers, floats, or False. The ORM applies the precision from digits at save time.


One important note for Odoo development: do not compare Float values with == in Python. Because of how floating-point arithmetic works at the hardware level, values that look equal may not be. Use float_compare and float_is_zero from odoo.tools.float_utils instead, which respect the field precision defined in your Odoo data model.

Business Use Cases


The Float field appears across nearly every module in an Odoo implementation. Here are five practical examples from real business workflows.


Sales: Discount Percentages on Order Lines

The native discount field on sale.order.line is a Float field. When a sales rep applies a 15% discount, Odoo stores 15.0 and applies it to the unit price calculation. This value flows through to printed quotes and customer invoices, and it participates in margin reports. Getting discounts right matters for both customer communication and business profitability analysis.


Inventory: Product Weights and Volumes

Products in Odoo have native weight and volume fields, both Floats. A product weighing 2.5 kg or occupying 0.003 m3 needs decimal precision that an Integer field simply cannot provide. These values feed directly into shipping cost calculations and carrier integrations. If you are using Odoo with a delivery connector, accurate Float values in weight and volume determine the shipping rate returned by the carrier API.


Accounting: Tax Rates

Tax rates on account.tax are Float fields. A standard 21% VAT is stored as 21.0, a reduced rate might be 6.0 or 5.5. The Odoo accounting engine reads these values to calculate tax amounts on every invoice and vendor bill. Precision matters here because small rounding differences can accumulate over hundreds of transactions and cause discrepancies in tax reports.


Manufacturing: Bill of Materials Quantities

In Odoo Manufacturing, the quantity of each component in a bill of materials is a Float field. A recipe might call for 0.75 liters of a liquid ingredient or 2.5 kg of a raw material. Float fields handle these fractional quantities naturally. Using an Integer field in this context would force rounding and introduce production errors that compound over time.


Purchase: Price Factors and Vendor Margins

When setting up vendor pricelists or markup rules, Float fields store the multipliers and margins. A margin factor of 1.25 (25% markup) or a discount factor of 0.85 (15% off list price) are typical values in purchase pricing logic. These Float values feed into automated price computations on purchase orders and help purchasing teams maintain consistent pricing across vendors.

Creating or Customizing the Float Field


There are three main ways to add a Float field to an Odoo model, depending on your technical context and deployment approach.

Using Odoo Studio (No Code)

Odoo Studio is the built-in low-code customization tool. To add a Float field without writing any code:


  1. Open Odoo Studio from the main menu.
  2. Navigate to the form where you want the field.
  3. Drag a Decimal Number field from the field picker onto the form.
  4. Set the label, default value, and number of decimal places in the properties panel.
  5. Save and close Studio.

Studio creates the field with an x_studio_ prefix and adds it to the form view automatically. No database work needed on your side. This is one of the most accessible ways to create fields in Odoo for users who want Odoo customization without technical complexity.


Using Python in a Custom Module

For developers building Odoo modules, Float fields are defined directly in Python. This is the recommended approach for any Odoo development that needs to be version-controlled and deployed across multiple environments:


from odoo import fields, models

class ResPartner(models.Model):
    _inherit = 'res.partner'

    x_credit_limit = fields.Float(
        string='Credit Limit',
        digits=(12, 2),
        default=0.0,
        help='Maximum outstanding balance allowed for this customer.',
    )

After adding the field to the model, include it in the relevant view XML so it appears in the interface. Odoo handles the database column automatically on module install or upgrade. This is the standard Odoo developer guide approach for any serious Odoo customization work.


Using the XML-RPC API

If you are managing Odoo customizations programmatically, for example through a deployment script or a remote configuration notebook, you can create Float fields via the XML-RPC API:

field_id = models.execute_kw(
    ODOO_DB, uid, ODOO_API_KEY,
    'ir.model.fields', 'create',
    [{
        'name': 'x_custom_coefficient',
        'field_description': 'Custom Coefficient',
        'model_id': model_id,
        'ttype': 'float',
        'state': 'manual',
    }]
)

The state: manual value tells Odoo this field was created manually rather than by a module, which is the correct setting for fields created through Studio or the API. Decimal precision for API-created Float fields is managed through the Decimal Accuracy settings in the technical menu. This is the approach Dasolo uses for remote field creation as part of automated Odoo configuration scripts.

Best Practices


1. Use named precision groups for standard values

Instead of hardcoding digits=(6, 2), reference a precision group like 'Product Price' or 'Product Unit of Measure'. This allows users with technical access to adjust precision from the interface without code changes, and it aligns your custom fields with the same precision as native Odoo fields in the same context.


2. Use Monetary for currency amounts, not Float

This is the single most important point in this list. The Monetary field is specifically designed for amounts that have a currency. It links to a currency field on the same model, handles rounding per currency rules, and works correctly in multi-currency environments. Using a Float field for invoice amounts or sale prices will cause rounding inconsistencies and break multi-currency reporting.


3. Always set a default value

Set default=0.0 for numeric fields that should start at zero. Without a default, the field value is False (null in the database) until the user fills it in. This can cause unexpected errors in computed fields or Python methods that assume a numeric value is always present.


4. Set group_operator for reports

If a Float field represents a quantity or amount that makes sense to sum in reports, add group_operator='sum'. If it represents a rate or a percentage where averaging makes more sense, use group_operator='avg'. Getting this right ensures that pivot tables and graph views aggregate your data meaningfully, which matters a lot in Odoo database fields used for analysis.


5. Document your percentage conventions

If a Float field stores a percentage, be explicit about whether it uses a 0-100 range (like the native discount field: 15.0 for 15%) or a 0-1 range (like some margin fields: 0.15 for 15%). Mixing these conventions across a data model produces silent calculation errors that are very difficult to trace after the fact.


Common Pitfalls


Using Float for monetary amounts

Float fields carry no currency information. A Float field showing 1500 could be euros, dollars, or anything else. In a multi-currency Odoo setup, this leads to incorrect totals on financial reports. Use the Monetary field type for any amount that has a currency.


Not setting the digits parameter

Without explicit digits, Odoo applies a default Float precision of 2 decimal places. This is fine for prices but not for fields that need 4 or 6 decimal places, such as exchange rates or unit conversion factors. A conversion factor silently rounded to 2 decimal places will produce compounding errors across every transaction that uses it.


Comparing Float values with == in Python

Due to how floating-point numbers work at the hardware level, two Float values that look identical may not be equal when compared with ==. For example, 0.1 + 0.2 == 0.3 evaluates to False in Python. Use float_compare(value1, value2, precision_digits=2) and float_is_zero(value, precision_digits=2) from odoo.tools.float_utils for reliable comparisons. This is a common point in any Odoo technical tutorial on the subject.


Using Float when Integer is the right choice

If a field always holds whole numbers, like a count, a number of packages, or a sequence number, use an Integer field instead. Float fields for whole numbers are not technically wrong, but they create unnecessary confusion and invite users to enter decimal values where none make sense in the business context.


Not handling False values in compute methods

A Float field without a default value returns False (not 0.0) when no value has been set yet. If you are computing based on Float fields, always check for False before doing arithmetic, or simply add default=0.0 to the field definition. This prevents TypeError exceptions in compute methods that only surface during real data scenarios.

Conclusion


The Float field is a fundamental building block of the Odoo data model. It handles decimal numbers across prices, quantities, rates, and measurements, and it does so reliably when configured with the right precision and defaults.


The main things to keep in mind: use named precision groups for standard values, use Monetary instead of Float for currency amounts, always set a default value, and document your conventions for percentage fields. These habits prevent the most common data quality issues before they have a chance to cause problems in production.

Whether you are adding fields through Odoo Studio, writing a custom Python module, or managing your data model programmatically via the Odoo ORM or XML-RPC API, getting Float fields right from the start makes for a cleaner and more reliable implementation overall.

At Dasolo, we help companies implement, customize, and optimize Odoo across all departments. Whether you need help designing a clean data model, adding custom fields to your forms, or building a full Odoo module from scratch, our team is here to support you. Reach out to us and let's talk about your Odoo project.

Float Field in Odoo: The Complete Guide
Dasolo March 6, 2026
Share this post
Sign in to leave a comment