many2one_barcode
many2one_barcode is the smallest widget on this site with a real job: it is the standard many2one with the mobile barcode scanner permanently switched on, so warehouse and accounting users fill product fields by pointing a camera at a label.
| Technical name | many2one_barcode |
|---|---|
| Field types | many2one |
| Views | form, list |
| Module | web, present in every Odoo database |
| Used in core | 4 occurrences across 3 modules: sale, account, purchase (product fields in line forms) |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0 |
| No-code setup | No dedicated Studio entry; apply widget="many2one_barcode" in XML on a many2one field. |
| Alternatives | many2one, package_m2o, many2one_uom |
What the Barcode many2one widget does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
no_create | boolean | Inherited from many2one. Blocks quick create and Create and Edit, so a scan or search can only select existing records, the usual choice for product fields.(default: false) |
no_open | boolean | Inherited from many2one. Removes the internal link to the selected record in readonly mode.(default: false) |
no_quick_create | boolean | Inherited from many2one. Hides only the inline Create "x" entry in the dropdown.(default: false) |
no_create_edit | boolean | Inherited from many2one. Hides the Create and Edit dialog entry.(default: false) |
search_threshold | integer | Inherited from many2one, new in 19. Delays autocomplete until this many characters are typed; does not affect the scan path, which fires a search immediately with the full decoded value.(since Odoo 19.0) |
placeholder_field | field name | Inherited from many2one, new in 19. Reads the input placeholder from another field on the record.(since Odoo 19.0) |
create_name_field | field name | Undocumented, inherited from many2one: read in extractM2OFieldProps but never declared. Sets which field receives the typed text on quick create. |
Do not pass can_scan_barcode in options here; the widget overrides it with true unconditionally. If you want an optional scanner on some views, use the plain many2one widget with the undocumented can_scan_barcode option instead.
Working examples
From defaultProps to a hardcoded flag, and how matching really works
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Only mechanical framework changes in the development branch; see below. |
| Odoo 19.0 | Verified | Verified against the shipped source; scan flag now unconditional in extractProps. |
| Odoo 18.0 | Verified | Subclass implementation with canScanBarcode as a default prop; same behavior. |
| Odoo 17.0 | Verified | Same subclass implementation as 18.0. |
| Odoo 16.0 | Verified | Present with the same defaultProps mechanism, verified in the 16.0 source. |
No XML changes are needed across 16 to 19. Note the subtle hardening in 19: the scan flag can no longer be overridden off, because it moved from a default prop to an unconditional extractProps value.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| No barcode icon appears in the field | The scanner affordance only renders in Odoo's mobile environment with camera access; desktop browsers do not show it. Test in the Android or iOS app, or a mobile browser with camera permission granted. |
| Scanning a valid product barcode finds nothing | Matching runs through the model's name_search; it only works when that search covers barcode values, as product.product does. Confirm the barcode is stored on the record and the target model's name_search includes it. |
| A scan opens the dropdown instead of selecting the record | More than one record matched the scanned value, so the widget falls back to the normal selection list. Ensure barcodes are unique on the target model. |
| You want the scanner optional per view, not always on | This widget hardcodes canScanBarcode true in extractProps since 19. Use the plain many2one widget with options="{'can_scan_barcode': True}" where you want it. |
Barcode many2one widget vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
many2one_barcode | Product and asset fields that mobile users fill by scanning labels | Standard many2one with the mobile scanner permanently enabled via one hardcoded prop |
| many2one | Any relational field without scanning | Scanner off by default, switchable via the undocumented can_scan_barcode option |
| package_m2o | Stock package fields in operations | Context driven display name logic for source and destination packages |
| many2one_uom | Unit of measure selection next to quantities | Pairs the m2o with product and quantity fields for UoM logic |
Frequently asked questions
What does the many2one_barcode widget do in Odoo?+
Why do I not see the scan icon on my desktop?+
Which fields use many2one_barcode in standard Odoo?+
Can I disable scanning on this widget for some views?+
Does many2one_barcode support normal many2one options?+
Make your product fields scannable this week
One widget swap turns order entry into point and scan, but only if barcodes are clean and unique. We set up scannable fields, dedupe product barcodes and extend name_search where scans must match custom codes.
Set up barcode entry