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.
| Technical name | confirm_boolean |
|---|---|
| Field types | boolean |
| Views | form, list |
| Module | stock_account, inventory valuation |
| Used in core | 1 occurrence, the lot valuation toggle on the product form in stock_account |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0 |
| No-code setup | No. The warning and the guarded field are fixed in the source |
| Alternatives | boolean_toggle, boolean, upgrade_boolean |
What the confirming toggle does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
lot_valuated | field read by literal name | The 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) |
autosave | boolean | Inherited 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
Confirming in one direction only
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Byte-identical to Odoo 19 on the development branch. |
| Odoo 19.0 | Verified | Verified against the shipped source. Unchanged in substance from Odoo 18. |
| Odoo 18.0 | Verified | First version. |
| Odoo 17.0 | Not available | Widget does not exist. |
| Odoo 16.0 | Not available | Widget 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
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| No confirmation appears | Either 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 immediately | Intended. 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 nothing | The substituted checkbox only forwards clicks that land on the input itself. Click the switch directly. |
| It confirms on the wrong field | The 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 case | The message is a fixed string in the source. Copy the widget and supply your own wording. |
| Cancelling left the toggle in the new position | It 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
| Widget | Best for | Key difference |
|---|---|---|
confirm_boolean | Switches whose off position loses information that cannot be recovered | Confirms in one direction only, names the consequence, and saves immediately once confirmed |
| boolean_toggle | Ordinary settings shown as a switch | No confirmation and no immediate save |
| boolean | A plain checkbox | Checkbox styling, otherwise the same lack of guarding |
| upgrade_boolean | Settings that require a plan upgrade | Intercepts the toggle to show an upsell rather than a data warning |
Frequently asked questions
When does confirm_boolean ask for confirmation?+
Why does it save straight away?+
Can I use it on another boolean?+
Why does clicking the label not toggle it?+
Which versions have it?+
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