Skip to main content
iVentureTeam

label_selection

Paid in green, Cancelled in red: label_selection paints a selection value as a colored label using one option, classes, a plain mapping from value to color. It displays; it never edits.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 12, 2026Updated August 12, 20265 min read
Odoo 19 list view with a status column rendered by label_selection showing green, yellow and red labels per row.
Technical namelabel_selection
Field typesselection
Viewslist, form, kanban (display only in all of them)
Moduleweb, present in every Odoo database
Used in core16 occurrences across 13 modules, including account, stock, point_of_sale, survey, lunch, payment
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0
No-code setupNo. The classes mapping is written in view XML
Alternativesbadge, selection_badge, statusbar

What the Label Selection widget does

label_selection is a one-job widget: take the current value of a selection field and render it as a colored label. The color comes from its single option, classes, a dictionary from selection keys to Bootstrap contextual color names. The template is a single span with badge text-bg- plus the resolved color; any value not in the map renders in primary, the source's hardcoded fallback.

Its defining property is what it lacks: an edit mode. Most display-leaning widgets at least switch to an input when the form is editable; this one's template has no second branch. Whether the view is readonly or not, the label is what you get, and the value can only change through other means, server logic, buttons, or another widget elsewhere in the view.

The text inside the label is the selection's display label run through Odoo's formatter, so it is translated and human readable, never the technical key.

What this means for your team

Status columns are read a hundred times more often than they are edited. This widget optimizes exactly that ratio: color carries the state to a scanning eye faster than text, and the enforced readonly-ness makes it impossible to bump a document's state with a stray click in an editable list, a real hazard with clickable state widgets.

The palette is a governance tool if you are disciplined: green for done, yellow for pending, red for failed, consistently across every screen. Because each view declares its own classes map, that consistency is a convention you maintain, not something Odoo enforces, worth an internal style note when several people write views.

Payment acquirers are core's showcase: transaction states render with this widget so finance staff can scan hundreds of rows for the red ones. That pattern, big lists scanned for exceptions, is where the widget earns its keep.

Supported options in Odoo 19

Verified against label_selection_field.js in the Odoo 19.0 web module: one supported option, one hardcoded fallback, nothing else read anywhere in the file.

OptionTypeWhat it does
classesobject (map)Maps selection keys to Bootstrap contextual color names, e.g. {'done': 'success', 'cancel': 'danger'}. Values not in the map render with the hardcoded fallback color primary.

The map keys are selection keys, not labels. Write {'done': 'success'}, not {'Done': 'success'}, keys are matched against the stored value. Valid color names are the Bootstrap contextual set (primary, secondary, success, danger, warning, info, light, dark); anything else produces an unstyled class and a gray-ish label.

Working examples

Payment state column, core style

<field name="state" widget="label_selection"
       options="{'classes': {'draft': 'info', 'done': 'success', 'cancel': 'danger', 'error': 'danger'}}"/>

Minimal: color only the problem states

<field name="state" widget="label_selection"
       options="{'classes': {'failed': 'danger', 'pending': 'warning'}}"/>

Unmapped states (confirmed, done) fall back to the primary color; only the states worth noticing get their own.

label_selection vs badge: the practical difference

Odoo has two readonly label widgets for selections and the choice confuses every implementer once.

Where the color comes from. This widget colors from its classes option, declared per view. The badge widget colors from decoration-* attributes on the field element, expressions evaluated against the record, which means badge can color on conditions beyond the field's own value.

Types. This widget accepts only selection fields; badge also takes many2one and char.

Failure modes. Here, an unmapped value silently renders primary. With badge, a decoration expression error breaks louder. Silent fallback is friendlier in production and easier to miss in review; check your map covers every selection key, including ones added later, a classic source of the mystery blue label.

Rule of thumb: coloring by the field's own value with a static map, use this widget; coloring by other fields or conditions, use badge.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. No changes visible on the development branch; see below.
Odoo 19.0VerifiedVerified against the shipped source and template.
Odoo 18.0VerifiedThe 18.0 and 19.0 files are byte-identical. Verified directly.

What is changing in Odoo 20

Odoo 20 is expected at Odoo Experience in Brussels, 24 to 26 September 2026. The changes below are read from the public development branch and are not final until release.

No changes. The option, the primary fallback and the registration are identical on the development branch; the component is ported to the new Owl props system (the default mapping moves inline, with no behavioral effect). The 18.0 and 19.0 files are byte-identical too, making this one of the most stable widgets in the set. We re-verify after release.

Common problems and fixes

SymptomCause and fix
Every label is blueThe classes map is missing, misspelled, or keyed by labels instead of selection keys; everything falls back to primary. Key the map by the technical selection keys and check the option syntax.
One state shows the wrong color after adding a selection valueThe new key is not in the map, so it renders primary. Extend the classes map whenever the selection grows; the widget will not warn you.
Users cannot change the statusBy design: the template has no edit mode. Expose the state through statusbar, selection_badge or buttons elsewhere in the view.
Label shows the technical key instead of the labelThe field is rendered without the widget or is not a selection field. Confirm widget="label_selection" and a selection field; the widget always prints the translated label.
Custom color name has no effectOnly Bootstrap contextual names produce text-bg-* classes that exist in the stylesheet. Stick to primary, secondary, success, danger, warning, info, light, dark, or add matching CSS for custom names.

Label Selection widget vs the alternatives

WidgetBest forKey difference
label_selectionStatus columns scanned for exceptionsStatic value-to-color map, primary fallback, structurally incapable of editing
badgeLabels colored by conditions beyond the field's valueColors via decoration-* expressions; also takes many2one and char
selection_badgeChoosing between few options with pillsEditable; renders plain text in readonly
statusbarPipeline stages at the top of formsEditable arrow bar showing all stages

This widget shows state; it never changes it. When users must also set the value, pair the list's label with an editable widget on the form, statusbar for pipeline stages, selection_badge for quick switches, or plain selection.

Frequently asked questions

How do I color a status field in an Odoo list view?+
Render it with widget="label_selection" and map keys to colors: options="{'classes': {'done': 'success', 'cancel': 'danger'}}". Unmapped values render in the default primary color.
Which colors can I use?+
The Bootstrap contextual set: primary, secondary, success, danger, warning, info, light, dark. The widget builds text-bg-<name> classes, so only names with matching styles work out of the box.
Why is my label blue when I mapped it to another color?+
Blue is the primary fallback, which means the lookup missed: the map key does not exactly match the stored selection key. Check for typos and label-vs-key confusion.
Can users edit the value with this widget?+
No, and not because of a readonly flag: the template simply has no edit rendering. Change the value through another widget, a button, or server logic.
label_selection or badge, which should I use?+
Color from the field's own value with a static map: label_selection. Color from conditions or other fields: badge with decoration attributes. badge also supports many2one and char fields.
Does it work on kanban cards?+
Yes, it renders its span anywhere the field is placed, and being display-only it is safe on cards where accidental edits would be a problem.

Can your team see problems at a glance?

Color-coded lists, exception-first dashboards, KPIs that surface the five records needing action today: operational visibility in Odoo is mostly configuration, done right. We tune views, filters and dashboards across Odoo 16 to 19 so the screen answers before anyone asks.

Book a free consultation

How this page was produced

This page was verified by reading label_selection_field.js and its single-span QWeb template in the Odoo 19.0 web module, confirming the classes option, the primary fallback and the absence of any edit branch, with the same file compared on the 18.0 branch (byte-identical) and the development branch. Spotted an error or a version difference? Tell us and we will correct the page.