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.
| Technical name | float_without_trailing_zeros |
|---|---|
| Field types | float, monetary |
| Views | form |
| Module | hr (in Odoo 16: hr_holidays) |
| Used in core | 3 occurrences across 1 module: time off accrual plan level forms in hr_holidays |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0 |
| No-code setup | No. Applied via the widget attribute in view XML |
| Alternatives | float, float_time, percentage, monetary |
What the Trimmed float does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
digits | digits | Inherited 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_zeros | boolean | Inherited 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_readable | boolean | Inherited from float. Compact notation such as 500G; combined with the trim it rarely makes sense in accrual sentences. |
step | number | Inherited from float. Increment applied by the input's up and down arrows while editing. |
enable_formatting | boolean | Inherited 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
Sixteen lines, three versions, one blind spot
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. File byte-identical on the development branch; we re-verify after launch. |
| Odoo 19.0 | Verified | Verified against the shipped source. Inner trailing zeros now trimmed, so 2.50 renders 2.5. |
| Odoo 18.0 | Partial / changed | Only all-zero decimal tails trimmed: 2.00 renders 2 but 2.50 stays 2.50. |
| Odoo 17.0 | Partial / changed | Same single-regex behavior as 18; widget moved to the hr module this release. |
| Odoo 16.0 | Partial / changed | Legacy 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
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| 2.50 still shows both decimals on Odoo 17 or 18 | Those 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 editing | Only 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 HR | Registration lives in the hr module. Install hr, or use float with hide_trailing_zeros on Odoo 19+. |
| Trimming also wanted in list view cells | The 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 entirely | enable_formatting was set to false, bypassing locale formatting. Remove that option unless raw display is intended. |
Trimmed float vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
float_without_trailing_zeros | Numbers embedded in sentence-style HR configuration | Regex trim of the readonly display only, editing untouched |
| float | General numeric fields on Odoo 19+ | hide_trailing_zeros option trims at the formatter level, lists included |
| float_time | Durations shown as HH:MM | Reformats to time notation instead of trimming decimals |
| percentage | Ratios shown as percentages | Multiplies and suffixes rather than trimming |
| monetary | Money with currency symbols | Currency-driven decimals that should usually not be trimmed |
Frequently asked questions
What exactly does float_without_trailing_zeros change?
Why does 2.50 render differently on Odoo 18 and 19?
Should I use this widget or float with hide_trailing_zeros?
Does the widget round values?
Can it be used outside HR views?
Anything changing in Odoo 20?
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