radio_followed_by_element
New in Odoo 19: radio_followed_by_element physically moves other form elements so they sit inline after a chosen radio option. It powers the accrual plan sentences in Time Off, and it is the most DOM-invasive field widget in core.
| Technical name | radio_followed_by_element |
|---|---|
| Field types | selection, many2one |
| Views | form |
| Module | hr |
| Used in core | 3 occurrences across 1 module: accrual plan level forms in hr_holidays |
| Versions | Odoo 20.0, Odoo 19.0 |
| No-code setup | No. Applied via the widget attribute in view XML |
| Alternatives | radio, selection, selection_badge, float_without_trailing_zeros |
What the Radio with inline element does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
links | object | Required. Maps radio option values to DOM element ids: each element is moved to sit directly after its option. Keys must be usable inside a CSS attribute selector.(since Odoo 19.0) |
observe | string | Required. The name attribute of the container watched by a MutationObserver; every re-render inside it re-triggers the element moves. Must exist when the widget mounts.(since Odoo 19.0) |
There are no optional knobs here. Omitting links or observe is not a degraded mode, it is a props validation error that breaks the view. Note also that this widget's extractProps replaces the base radio's entirely, so the inherited horizontal option is accepted by the schema but never reaches the component: these radios are always vertical.
Working examples
How the DOM surgery actually works
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Formatting-only changes on the development branch; behavior identical. |
| Odoo 19.0 | Verified | Widget introduced this release; verified against the shipped source. |
| Odoo 18.0 | Not available | Widget does not exist. |
| Odoo 17.0 | Not available | Widget does not exist. |
| Odoo 16.0 | Not available | Widget does not exist. |
Upgrade note. The widget does not exist before Odoo 19. Views backported to 18 must fall back to conventional layouts, or carry the widget file along as a custom module, which works since it only depends on the standard radio field.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| View crashes with a props validation error | links and observe are required props; one is missing from options. Provide both options on every use of the widget. |
| The companion element renders in its original spot | The element id in links does not match, or the option's data-value key is wrong. Check ids and selection values character for character; matching is exact. |
| Error mentioning getElementsByName or observe on mount | No element with the observed name attribute exists when the widget mounts. Ensure the container named in observe is present and not conditionally hidden at load. |
| Elements jump back after an onchange, then snap into place | Odoo re-rendered the observed container; the observer re-runs the move just after. No fix needed; a brief flicker on heavy re-renders is inherent to the approach. |
| Radios will not render horizontally despite the horizontal option | This widget's extractProps replaces the base radio's and never passes orientation. None without a custom widget; the layout is vertical by design. |
| Two widgets on one form move each other's elements | data-value matching queries the whole document and takes the first match. Keep selection values distinct between co-rendered instances. |
Radio with inline element vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
radio_followed_by_element | Sentence-style choices with inline companion inputs | Physically relocates DOM elements after their radio option |
| radio | Plain visible-choice selections | No DOM movement; supports the horizontal option this variant drops |
| selection | Compact dropdown choices | One closed control, no inline companions |
| selection_badge | One-click choice pills | Badges instead of radios, no companion mechanism |
| float_without_trailing_zeros | The numbers inside those same accrual sentences | Formats a value rather than arranging the layout |
Frequently asked questions
What problem does radio_followed_by_element solve?+
Are the links and observe options really mandatory?+
Can the moved element contain live fields?+
Why do my radios ignore the horizontal option with this widget?+
Is this widget available in Odoo 17 or 18?+
How stable is this pattern for custom development?+
Forms your team reads like sentences?
Inline layouts, dependent inputs, and guided configuration screens take Odoo beyond stock view XML. We design and build these UX-heavy forms, custom widgets included, so complex policies become screens people fill in correctly the first time. Odoo 16 through 19.
Book a free consultation