Skip to main content
iVentureTeam

confirm_boolean

A switch that stops and asks before it loses data. It only asks in one direction, and once you confirm it saves straight away rather than waiting for the form.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 27, 2026Updated September 2, 20265 min read
Technical nameconfirm_boolean
Field typesboolean
Viewsform, list
Modulestock_account, inventory valuation
Used in core1 occurrence, the lot valuation toggle on the product form in stock_account
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0
No-code setupNo. The warning and the guarded field are fixed in the source
Alternativesboolean_toggle, boolean, upgrade_boolean

What the confirming toggle does

Some settings are cheap to turn on and expensive to turn off. Valuing stock per lot or serial number is one: while it is on, each lot carries its own cost, and turning it off collapses all of them to a single value. The individual costs are not recoverable afterwards.

This widget is the toggle for that setting, with a confirmation in front of the destructive direction. Switching it on behaves like any other toggle. Switching it off opens a dialog naming the consequence and waits for an answer.

Once confirmed, it does something a plain toggle does not: it writes the change and saves the record in the same operation. A setting this consequential should not be left sitting unsaved on a form where it might be discarded by accident or applied by surprise later.

What this means for your team

Confirmation dialogs are usually a sign that something is designed badly, but not always. Where an action genuinely loses information and cannot be undone, the dialog is the cheapest available safeguard, and the important part is that it names the consequence rather than asking a generic question.

The immediate save is the other half. A destructive setting that stays pending on a form creates a window where the record's state and the screen disagree, and where a later save applies a change nobody remembers making. Committing at the moment of confirmation closes that window.

The pattern generalizes to any irreversible switch: guard one direction, name the consequence, and commit on confirmation. What does not generalize is this particular widget, because the field it checks is written into the source.

Supported options in Odoo 19

The widget declares no options of its own. It spreads the toggle widget's descriptor, so the options below are inherited. The confirmation itself is not configurable, as described in the note. Read from boolean_confirm.js and the boolean toggle field, Odoo 19.0.

OptionTypeWhat it does
lot_valuatedfield read by literal nameThe guarded setting. The confirmation appears only when this field is currently true and the new value is false, regardless of which field the widget renders.(since Odoo 18.0)
autosavebooleanInherited from the toggle widget. Note that this widget saves explicitly on confirmation regardless, so the option has little effect here.(default: true)

The guard is hardcoded twice over. The widget decides whether to confirm by reading one specific field on the record by literal name, not the field it was placed on, and the warning text is a fixed string in the source. So it guards exactly one setting, and putting it on any other boolean will either never confirm or confirm for the wrong reason.

Working examples

The core usage

<field name="lot_valuated" widget="confirm_boolean"
       invisible="tracking == 'none'"/>

The field and the guard coincide, which is the only configuration in which the widget behaves as intended. It is hidden when the product is not tracked at all.

What happens on confirmation

# written and saved in one operation
record.update({ lot_valuated: false }, { save: true })

Not left pending. Cancelling writes nothing at all.

The plain toggle

<field name="lot_valuated" widget="boolean_toggle"/>

Same appearance, no warning and no immediate save.

Confirming in one direction only

The change handler is the whole widget. It builds a small function that writes the new value with saving switched on, then decides whether to call it directly or behind a dialog. The dialog is shown only when the guarded field is currently true and the new value is false, so turning the setting on is never interrupted.

Cancelling supplies an empty callback, which means nothing is written and the toggle returns to its previous state on the next render. There is no partial state to clean up.

The widget also substitutes a checkbox subclass. That subclass prevents the default action on every click and then only forwards the change when the click landed on the input element itself, which stops clicks on the surrounding label or padding from toggling a setting this consequential.

Two limits are worth stating for anyone tempted to reuse it. The guarded field is read by literal name, so the widget is bound to one setting rather than to whatever field it renders. And the warning text is fixed, so the consequence it names is specific to lot valuation.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. Byte-identical to Odoo 19 on the development branch.
Odoo 19.0VerifiedVerified against the shipped source. Unchanged in substance from Odoo 18.
Odoo 18.0VerifiedFirst version.
Odoo 17.0Not availableWidget does not exist.
Odoo 16.0Not availableWidget does not exist.

Upgrade note. The widget is new in Odoo 18 and is unchanged in substance in Odoo 19. Databases coming from Odoo 17 gain the confirmation with the standard product views, and there is nothing to migrate.

What is changing in Odoo 20

Odoo 20 is expected at Odoo Experience in Brussels, 24 to 26 September 2026. The development branch is unstable and this may still change; we re-verify the page after release.

Byte-identical. The file on the development branch matches Odoo 19 exactly, including the hardcoded field name and warning text.

Common problems and fixes

SymptomCause and fix
No confirmation appearsEither the setting is being switched on, which is never guarded, or the guarded field is not currently true. Expected. Only switching the setting off from an on state is confirmed.
The change saved immediatelyIntended. Confirming writes and saves in one operation rather than leaving the change pending. Nothing to fix; a pending destructive setting is worse.
Clicking the label does nothingThe substituted checkbox only forwards clicks that land on the input itself. Click the switch directly.
It confirms on the wrong fieldThe guard reads one field by literal name, not the field the widget renders. Use it only on that setting, or copy the widget with your own field name.
The warning text is wrong for my caseThe message is a fixed string in the source. Copy the widget and supply your own wording.
Cancelling left the toggle in the new positionIt should not; cancelling writes nothing and the next render restores it. Reload the form and check for a customization writing the field elsewhere.

Confirming toggle vs the alternatives

WidgetBest forKey difference
confirm_booleanSwitches whose off position loses information that cannot be recoveredConfirms in one direction only, names the consequence, and saves immediately once confirmed
boolean_toggleOrdinary settings shown as a switchNo confirmation and no immediate save
booleanA plain checkboxCheckbox styling, otherwise the same lack of guarding
upgrade_booleanSettings that require a plan upgradeIntercepts the toggle to show an upsell rather than a data warning

Use the plain toggle for ordinary settings. Where a switch is irreversible, the pattern here is worth copying but the widget is not, because its guard and its message are specific to lot valuation. A small copy with your own field name and wording is the honest approach.

Frequently asked questions

When does confirm_boolean ask for confirmation?+
Only when the guarded setting is currently on and you are switching it off. Turning it on is never interrupted, because that direction loses nothing.
Why does it save straight away?+
Because a destructive setting left pending on a form can be applied later by a save nobody remembers making. Confirming writes and saves in one operation.
Can I use it on another boolean?+
Not usefully. The guard reads one specific field by literal name rather than the field the widget renders, and the warning text is fixed in the source.
Why does clicking the label not toggle it?+
The widget substitutes a checkbox that only forwards clicks landing on the input itself, which prevents accidental toggles from clicks on surrounding space.
Which versions have it?+
Odoo 18 onwards, unchanged in substance, and byte-identical on the Odoo 20 development branch.

Valuation settings you can change without regret

Costing methods, lot valuation and the accounting entries behind them are hard to reverse once data exists. We review inventory valuation setups before the decision is made, on Odoo 16 through 19.

Book a free consultation

How this page was produced

The one-directional guard, the literal field read, the fixed warning text, the immediate save and the checkbox subclass were read from boolean_confirm.js on the Odoo 19.0 branch, with the inherited option set read from the boolean toggle field in web. The usage comes from stock_account/views/product_views.xml. Version coverage comes from the absence of the file on 16.0 and 17.0, a comparison with 18.0, and a byte comparison against the public development branch. Spotted an error? Tell us and we will correct the page.