Skip to main content
iVentureTeam

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.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 20, 2026Updated August 20, 20264 min read
Technical namemany2one_barcode
Field typesmany2one
Viewsform, list
Moduleweb, present in every Odoo database
Used in core4 occurrences across 3 modules: sale, account, purchase (product fields in line forms)
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0
No-code setupNo dedicated Studio entry; apply widget="many2one_barcode" in XML on a many2one field.
Alternativesmany2one, package_m2o, many2one_uom

What the Barcode many2one widget does

many2one_barcode renders a relational field exactly like the standard many2one, autocomplete, quick create, internal link, and adds one thing: the barcode scan affordance is always on. The entire widget is a component wrapper plus an extractProps that returns the base many2one props with canScanBarcode: true.

That flag activates the scanner integration built into the base Many2One component. In Odoo's mobile environment a barcode icon appears in the field; tapping it opens the camera, and the decoded value is pushed through name_search. When exactly one record matches, it is selected without any typing. When several match, the normal dropdown opens with the scanned text as the query.

On a desktop browser without the mobile barcode integration the icon simply never renders, which is why the widget is safe to put on views shared by both desktop and mobile users.

What this means for your team

This widget is the cheapest barcode win in Odoo. Before reaching for the full Barcode app, a sales or accounting team can make the product field on order and invoice lines scannable with a single XML attribute: warehouse staff scan the product label, the line fills, no typing, no picking the wrong variant from a list of lookalikes.

Because everything else stays standard many2one, the usual guardrails combine freely: no_create to prevent typo products, domains to restrict what may be scanned into the field, and from 19 a typeahead threshold for very large catalogs.

Supported options in Odoo 19

The widget declares no options of its own; canScanBarcode is hardcoded in extractProps and cannot be turned off from XML. Everything else is inherited from the standard many2one as declared in many2one_field.js.

OptionTypeWhat it does
no_createbooleanInherited 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_openbooleanInherited from many2one. Removes the internal link to the selected record in readonly mode.(default: false)
no_quick_createbooleanInherited from many2one. Hides only the inline Create "x" entry in the dropdown.(default: false)
no_create_editbooleanInherited from many2one. Hides the Create and Edit dialog entry.(default: false)
search_thresholdintegerInherited 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_fieldfield nameInherited from many2one, new in 19. Reads the input placeholder from another field on the record.(since Odoo 19.0)
create_name_fieldfield nameUndocumented, 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

The core usage from account_move_views.xml, a product field in the invoice line dialog:

<field name="product_id" widget="many2one_barcode"/>

Combined with inherited many2one options, scanning allowed but manual creation blocked:

<field name="product_id" widget="many2one_barcode"
       options="{'no_create': True, 'no_open': True}"/>

From defaultProps to a hardcoded flag, and how matching really works

For a widget this small, its history is a neat tour of Odoo's field framework refactors:

16 through 18: the widget subclassed Many2OneField and set canScanBarcode: true in defaultProps. Because it was only a default, a view could theoretically override it back to false.

19: the composition refactor rebuilt it as a plain component wrapping Many2One, and the flag moved into extractProps, where it is now unconditional. The refactor also left behind export const many2OneBarcodeField = {}, an empty object that nothing imports, while the real registration happens inline with buildM2OFieldDescription.

Matching semantics live in the base many2one, not here: the scanned string goes through the same name_search as typed text. That means barcode matching only works if the target model's name_search covers barcode values, as product.product does; on a model that only searches names, scanning fills the dropdown with the raw code as a query and usually finds nothing.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. Only mechanical framework changes in the development branch; see below.
Odoo 19.0VerifiedVerified against the shipped source; scan flag now unconditional in extractProps.
Odoo 18.0VerifiedSubclass implementation with canScanBarcode as a default prop; same behavior.
Odoo 17.0VerifiedSame subclass implementation as 18.0.
Odoo 16.0VerifiedPresent 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

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.

The widget is functionally untouched on master. The only diff is the framework wide props migration (useProps and the shared many2OneFieldProps export replacing the class props copy). The hardcoded canScanBarcode: true and the registration are identical. We will re verify this page against the released branch after the launch.

Common problems and fixes

SymptomCause and fix
No barcode icon appears in the fieldThe 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 nothingMatching 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 recordMore 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 onThis 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

WidgetBest forKey difference
many2one_barcodeProduct and asset fields that mobile users fill by scanning labelsStandard many2one with the mobile scanner permanently enabled via one hardcoded prop
many2oneAny relational field without scanningScanner off by default, switchable via the undocumented can_scan_barcode option
package_m2oStock package fields in operationsContext driven display name logic for source and destination packages
many2one_uomUnit of measure selection next to quantitiesPairs the m2o with product and quantity fields for UoM logic

Use many2one_barcode when one relational field should be scannable inside a normal form. For scan driven workflows across many operations, Odoo's dedicated Barcode app is the tool; for desktop only views the plain many2one keeps the UI cleaner.

Frequently asked questions

What does the many2one_barcode widget do in Odoo?+
It renders a many2one field with the mobile barcode scanner always enabled. Scanning a code runs the model's name_search with the decoded value and selects the record when exactly one matches.
Why do I not see the scan icon on my desktop?+
The scanner affordance is part of Odoo's mobile environment. On desktop browsers the widget renders as a completely normal many2one; that is by design and requires no configuration.
Which fields use many2one_barcode in standard Odoo?+
Four product fields in the line dialogs of sales orders, invoices and purchase orders (the sale, account and purchase modules).
Can I disable scanning on this widget for some views?+
No. Since Odoo 19 the flag is hardcoded in extractProps. Use the plain many2one widget instead, optionally with the undocumented can_scan_barcode option where scanning is wanted.
Does many2one_barcode support normal many2one options?+
Yes, all of them: no_create, no_open, no_quick_create, no_create_edit, plus search_threshold and placeholder_field from 19. Only the scan flag is fixed.

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

How this page was produced

This page was verified by reading the Odoo 19.0 web module source at views/fields/many2one_barcode/many2one_barcode_field.js together with the base many2one's option declarations and scanner integration, then diffing the 16.0 and 18.0 branches and the public development branch. The scan flow was confirmed on a clean Odoo 19 database with the mobile app. Corrections are welcome via our contact page.