Skip to main content
iVentureTeam

float_without_trailing_zeros

Odoo's accrual plans say "1 day", not "1.00 days". float_without_trailing_zeros does that trimming with one regex, and since Odoo 19 the core float widget can nearly replace it.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 21, 2026Updated August 21, 20266 min read
Technical namefloat_without_trailing_zeros
Field typesfloat, monetary
Viewsform
Modulehr (in Odoo 16: hr_holidays)
Used in core3 occurrences across 1 module: time off accrual plan level forms in hr_holidays
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0
No-code setupNo. Applied via the widget attribute in view XML
Alternativesfloat, float_time, percentage, monetary

What the Trimmed float does

Time off accrual plans in Odoo are configured as sentences: "employee accrues 1 day every month, capped at 15 days". The numbers in those sentences are float fields, and a float formatted to the usual two decimals reads "1.00 day every month", which is technically fine and visually wrong. This widget exists to make those inline numbers read like prose.

It extends the standard float widget and overrides exactly one thing, the formattedValue getter, chaining two replacements: first (\.\d*?[1-9])0+$ drops zeros that follow the last significant decimal digit, turning 2.50 into 2.5, then \.0+$ drops a decimal part that is entirely zeros, turning 1.00 into 1. Everything else, parsing, editing, digits handling, validation, is the inherited float widget.

Because only the formatted display is touched, the field edits like any float: click into it and the input shows the standard representation, save and the trimmed version returns.

What this means for your team

This is a polish widget, and polish is the actual point. Configuration screens that read as sentences, accrual plans, pricing rules, thresholds, get skimmed by managers who approve them. "1.00 days" in the middle of a sentence is exactly the kind of trailing noise that makes a screen feel machine-written, and enough of it erodes confidence in what is being approved.

For customizers the practical question in 2026 is which tool to reach for. If you are building for Odoo 19 or later, the core float widget's hide_trailing_zeros option does the same visual job, works in list cells and during formatting generally, and needs no module dependency beyond web. This widget earns its keep when you must match core HR behavior exactly, when the view also targets 17 or 18 where the core option does not exist, or when you specifically want trimming only in readonly display while keeping full precision visible during edits.

One data note: the widget never rounds. A stored 1.25 with two display digits renders 1.25 either way; only zeros disappear. Nothing about accrual math changes.

Supported options in Odoo 19

Verified against float_without_trailing_zeros.js in the Odoo 19.0 hr module. The widget declares nothing of its own; the option surface is the inherited float set, of which the most relevant entries are below.

OptionTypeWhat it does
digitsdigitsInherited from float. Total and decimal digits used to format the value before the trim runs; the digits attribute on the field takes precedence over the option.
hide_trailing_zerosbooleanInherited from float since 19.0 and redundant here: the formatter-level trim covers what this widget's regex does. Do not stack both deliberately.(since Odoo 19.0)
human_readablebooleanInherited from float. Compact notation such as 500G; combined with the trim it rarely makes sense in accrual sentences.
stepnumberInherited from float. Increment applied by the input's up and down arrows while editing.
enable_formattingbooleanInherited from float. Disabling it bypasses locale formatting entirely, which also changes what the trim regex sees.(default: true)

Do not combine it with hide_trailing_zeros. Since 19 the inherited option already sets the formatter's trailing-zeros flag; stacking the widget's regex on top is harmless but pointless. Pick one mechanism, and prefer the core option on 19+ views that do not need this module's behavior.

Working examples

As core uses it in accrual plans

<field nolabel="1" class="me-1 o_field_accrual" name="added_value"
       widget="float_without_trailing_zeros"/>

The number sits inline before a unit selector, forming the accrual sentence.

With explicit precision

<field name="threshold" widget="float_without_trailing_zeros"
       options="{'digits': [16, 3]}"/>

Digits control the formatting before trimming: 1.200 renders as 1.2, 1.230 as 1.23.

The Odoo 19 core alternative

<field name="threshold" widget="float"
       options="{'hide_trailing_zeros': True}"/>

Same visual result on 19+, no hr dependency, and it also applies in editable lists.

Sixteen lines, three versions, one blind spot

Three version-archaeology facts define this widget better than its fourteen lines.

The 16 version trimmed only in readonly, differently. It lived in hr_holidays as a legacy-framework field that reformatted the readonly text through parseFloat, which incidentally also dropped trailing zeros after the decimal in its own way. The move to hr and the modern getter came in 17.

17 and 18 had a blind spot. Their single regex \.0+$ removed only decimal parts that were entirely zeros. An accrual of 2.50 days displayed as "2.50", while 2.00 displayed as "2". The second regex closing that gap, so 2.50 reads "2.5", appears in 19.0, and it is the kind of tiny inconsistency users notice on approval screens without being able to name it.

19 made the widget almost obsolete. The same release gave core float the hide_trailing_zeros option, implemented properly at the formatter level (trailingZeros: false), which also covers list rendering. The hr widget survives because core HR views still use it and because its trimming applies regardless of options passed. When patching or extending accrual views, either mechanism is fine; when building new views on 19+, the core option is the cleaner dependency.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. File byte-identical on the development branch; we re-verify after launch.
Odoo 19.0VerifiedVerified against the shipped source. Inner trailing zeros now trimmed, so 2.50 renders 2.5.
Odoo 18.0Partial / changedOnly all-zero decimal tails trimmed: 2.00 renders 2 but 2.50 stays 2.50.
Odoo 17.0Partial / changedSame single-regex behavior as 18; widget moved to the hr module this release.
Odoo 16.0Partial / changedLegacy implementation in hr_holidays trimming readonly text via parseFloat.

Upgrade note. The widget name is stable across 16 to 19, but it moved modules after 16 (from hr_holidays to hr) and gained the inner-zero trim in 19. Views referencing it keep working; only expect slightly different rendering of values like 2.50 when moving from 18 to 19.

What is changing in Odoo 20

Odoo 20 is expected at Odoo Experience in Brussels, 24 to 26 September 2026. These notes are read from the public development branch, which is unstable until feature freeze; we re-verify against the shipped release.

The file is byte-identical on master: same two regexes, same registration, no options added or removed. The inherited float widget on master continues to carry hide_trailing_zeros. Barring late changes, this page should hold for Odoo 20 as written, and the long-term question is simply whether Odoo eventually retires the hr widget in favor of the core option; nothing on the branch suggests it yet.

Common problems and fixes

SymptomCause and fix
2.50 still shows both decimals on Odoo 17 or 18Those releases trim only all-zero decimal parts; the inner-zero regex is 19-new. Upgrade, or accept the behavior; backporting means a tiny custom widget.
Full precision reappears while editingOnly the readonly formatted display is trimmed; the edit input uses standard float formatting. No fix needed; this is the designed split.
Widget not found on a database without HRRegistration lives in the hr module. Install hr, or use float with hide_trailing_zeros on Odoo 19+.
Trimming also wanted in list view cellsThe widget's getter affects its own rendering; list cells using the plain float formatter keep zeros. Use the core hide_trailing_zeros option, which works at the formatter level.
Values look unformatted entirelyenable_formatting was set to false, bypassing locale formatting. Remove that option unless raw display is intended.

Trimmed float vs the alternatives

WidgetBest forKey difference
float_without_trailing_zerosNumbers embedded in sentence-style HR configurationRegex trim of the readonly display only, editing untouched
floatGeneral numeric fields on Odoo 19+hide_trailing_zeros option trims at the formatter level, lists included
float_timeDurations shown as HH:MMReformats to time notation instead of trimming decimals
percentageRatios shown as percentagesMultiplies and suffixes rather than trimming
monetaryMoney with currency symbolsCurrency-driven decimals that should usually not be trimmed

On Odoo 19 and later, default to core float with hide_trailing_zeros unless you are matching HR's existing views. Below 19, this widget is the only zero-trimming option that needs no custom code.

Frequently asked questions

What exactly does float_without_trailing_zeros change?+
Only the readonly formatted display. The stored value, the edit input, digits handling, and validation are the inherited float widget untouched. Two regexes drop trailing zeros: 1.00 renders 1 and, since Odoo 19, 2.50 renders 2.5.
Why does 2.50 render differently on Odoo 18 and 19?+
Odoo 17 and 18 shipped a single regex that removed only all-zero decimal parts, leaving 2.50 intact. Odoo 19 added a second regex that trims zeros after the last significant digit. The difference is visible in the two branches' sources.
Should I use this widget or float with hide_trailing_zeros?+
On Odoo 19 and later, prefer widget="float" options="{'hide_trailing_zeros': True}": it needs only the web module and trims in lists too. Use the hr widget when matching core HR views or supporting 17 and 18, where the core option does not exist.
Does the widget round values?+
No. It removes zero characters from the formatted string and nothing else. A stored 1.25 always shows 1.25; precision and accrual math are unaffected.
Can it be used outside HR views?+
Yes, on any float or monetary field once hr is installed, since the registration lives there. For non-HR modules on Odoo 19+ the core option avoids the dependency.
Anything changing in Odoo 20?+
The development branch shows the file byte-identical to 19.0, and the core float alternative also remains. We re-verify after the September 2026 release.

Time off rules that read right and compute right?

Accrual plans, carryover rules, and allocation flows are where Odoo Time Off gets subtle. We configure and extend hr_holidays for real policies, including the display polish that makes approval screens trustworthy, on Odoo 16 through 19.

Book a free consultation

How this page was produced

This page was verified by reading float_without_trailing_zeros.js on the Odoo 19.0 branch and comparing the same widget across 16.0 (hr_holidays legacy version), 17.0, 18.0, and master, which is where the regex difference between releases was found. The inherited option list was read from core float_field.js. Rendering was checked on a clean Odoo 19 database with accrual plans configured, where the screenshot was captured. Corrections welcome via our contact page.