float_toggle
The float_toggle widget turns a float into a button that cycles through a fixed list of values on each click. It declares five options, and one of them is read by nothing.
| Technical name | float_toggle |
|---|---|
| Field types | float |
| Views | form, list |
| Module | web, present in every Odoo database |
| Used in core | 0 uses in Odoo 19 Community or Enterprise. Third-party timesheet and planning modules are its usual home. |
| Versions | Odoo 19.0, Odoo 20.0 |
| No-code setup | No. There is no Studio entry for this widget. |
| Alternatives | float_factor, selection, boolean_toggle, float_time |
What the float_toggle widget does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
range | list of numbers | The values the button cycles through, in order. Clicking past the last entry wraps to the first. A stored value that is not exactly in this list does not match, and the next click lands on the second entry rather than the first.(default: [0.0, 0.5, 1.0]) |
factor | number | Multiplier applied before matching against the range and divided back out when writing. Works exactly like the factor option on float_factor, so the range you write is expressed in displayed units rather than stored ones.(default: 1) |
digits | digits | Display precision as a [total, decimal] pair. If the field also carries a digits XML attribute, the attribute wins and this option is ignored, which a comment in the source flags as a historical accident. |
force_button | boolean | Named for what it does, not for what it is called internally: it sets disableReadOnly, which keeps the button clickable even when the field is readonly. The Odoo option label is Disable readonly.(default: false) |
type | string | <strong>Declared but never read.</strong> It appears in supportedOptions, so Studio and any options helper will offer it, but extractProps ignores it and the component has no matching prop. Setting it has no effect in Odoo 19 or Odoo 20. |
Two traps here, both verified in extractProps. First, type is declared as a supported option but is never read, so it is inert. Second, when both the digits attribute and the digits option are present, the attribute wins: the code checks attrs.digits first and only falls back to options.digits. A source comment calls this out as a historical accident that a future XML refactor could remove.
Working examples
The type option is declared and never used
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 19.0 | Verified | Verified against the shipped 19.0 source. Five options, one of them inert. |
| Odoo 20.0 | Verified | Adds hide_trailing_zeros. Nothing removed. |
One option added in Odoo 20, nothing removed.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| The type option has no effect | It is declared in supportedOptions but never read by extractProps. The option is inert. Remove it. If you need a formatting change, use digits, or hide_trailing_zeros on Odoo 20. |
| The first click jumps to the second value instead of the first | The stored value is not exactly present in range, so indexOf returns -1 and the increment lands on index 1. Make sure stored values match the range exactly, allowing for the factor, or widen the range to include them. |
| The digits option is ignored | The field also carries a digits attribute, which takes precedence in extractProps. Remove the attribute, or change the attribute instead of the option. Check inherited views, since the attribute may come from the parent. |
| Users cannot click the button on a readonly field | Default behavior. disableReadOnly is false unless you set it. Add options="{'force_button': True}". |
| A zero value still shows the button rather than an empty cell | The descriptor sets isEmpty to always return false, so the field is never treated as empty. Working as designed. Use a plain float widget if you want empty rendering. |
Float_toggle widget vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
float_toggle | A float that is really one of a few fixed values | One-click cycling, with no way to type a value outside the range |
| float_factor | A scaled float the user types freely | Same factor idea, but a normal input instead of a button |
| selection | A genuinely closed set of choices | Searchable and groupable, and shows every option at once |
| boolean_toggle | A two-state value | Boolean rather than float, so no arithmetic downstream |
| float_time | A float representing a duration | Renders hours and minutes and is freely typed |
Frequently asked questions
How do I change the values an Odoo float_toggle cycles through?+
Why does the type option on float_toggle do nothing?+
How do I make a readonly float_toggle still clickable?+
Does float_toggle change in Odoo 20?+
Click-to-set fields that fight your users?
A toggle is excellent when the value set is truly closed and miserable when it is not, and the difference only shows up months in. We design the field before we pick the widget, then build it for Odoo 16 through 19 with an eye on what Odoo 20 changes.
Book a free consultation