x2many_buttons
The x2many buttons widget renders a relation as a short row of clickable record buttons. It powers the "this document might be a duplicate of" banner on invoices.
August 16, 2026Updated August 16, 20265 min read
| Technical name | x2many_buttons |
|---|---|
| Field types | many2many, one2many |
| Views | form |
| Module | account |
| Used in core | 11 occurrences across 4 modules, including account, l10n_pl_bank_verification, sale, purchase |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0 |
| No-code setup | No. Placement and the records-shown cap are set in XML by a developer. |
| Alternatives | actionable_errors, many2many_tags, one2many |
What the x2many buttons widget does
What this means for your team
Working examples
Discard first, ask questions later
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | The development branch file is byte-identical to 19.0 at the time of writing. Re-verified after release. |
| Odoo 19.0 | Verified | Verified against the shipped source, including the new nb_records_shown attribute. |
| Odoo 18.0 | Partial / changed | Works, but always shows three inline buttons: nb_records_shown does not exist. |
| Odoo 17.0 | Not available | The widget does not exist in the 17.0 account module. |
| Odoo 16.0 | Not available | Not available. |
Upgrade note for 18 to 19. Odoo 18 always rendered three inline buttons; the nb_records_shown attribute does not exist there and is silently ignored if backported XML carries it. The discard-then-open behavior is identical in both versions.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| My unsaved edits vanished after clicking a record button | By design: the widget discards the current record before navigating, on both click paths. Save before clicking. There is no option to disable the discard. |
| Clicking a button raises a missing method error | The related model does not implement action_open_business_doc. Implement the method on the target model, returning the action to open one record. |
| nb_records_shown seems to be ignored | It was written inside options, or the database is Odoo 18 where the attribute does not exist. Set it as a plain attribute on the field tag, on Odoo 19 or later. |
| The overflow list shows generic columns instead of the duplicate-review layout | The dedicated list view is injected only when the related model is account.move. For other models, define a list view and point at it via a list_view_ref context key on an explicit action. |
| Buttons show record names where amounts would be more useful | Labels are display_name, which for moves can be switched to totals by context. Pass context="{'name_as_amount_total': True}" as the invoice form does. |
X2many buttons widget vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
x2many_buttons | Compact, clickable evidence of related records inside warning banners | Pure navigation: discards edits and opens records, never edits the relation |
| actionable_errors | Messages with fix buttons rather than record references | Renders a computed JSON of alerts, sorted by severity |
| many2many_tags | Relations users actively add to and remove from | Editable pills with search and create; no navigation on click by default |
| one2many | Child records with columns worth reading inline | Full embedded list, editable, and much heavier in a banner |
Frequently asked questions
What does the x2many_buttons widget do in Odoo?+
How do I control how many buttons are shown?+
Why does clicking a button discard my changes?+
Can I use x2many_buttons outside accounting?+
Does x2many_buttons change in Odoo 20?+
Duplicate payments still slipping through?
Odoo's duplicate banner is only as good as the detection rules behind it. We tune duplicate detection, build custom cross-reference checks on this widget, and tighten AP controls for teams processing serious invoice volume in Odoo.
Tighten your AP workflow