Added generic MPN barcode scanning (#13266)

* Added generic MPN barcode scanning

- Provides generic lookup against MPN
- Runs with lower priority (fallback only)
- Barcode plugins are now ordered by decreasing priority

* Apply suggestion from @matmair

* Bump internal priority

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
OliverandMatthias Mair authored and GitHub committed 2026-11-13 21:53:35 +11:00
1 parent 891553a9c7
commit 790112013b
12 files changed
+550 -5

No files matched your search

@@ -0,0 +1,42 @@
---
title: Manufacturer Barcode Plugin
---
## Manufacturer Barcode Plugin
The **Manufacturer Barcode Plugin** provides *fallback* barcode support for matching a scanned barcode against the manufacturer part number (MPN) of an existing [manufacturer part](../../purchasing/manufacturer.md).
It is intended for barcodes which are not handled by any of the supplier-specific barcode plugins (e.g. [DigiKey](./barcode_digikey.md) or [Mouser](./barcode_mouser.md)), but which still contain a manufacturer part number.
This plugin implements the [BarcodeMixin](../mixins/barcode.md) mixin to provide custom barcode support - see [Barcode Plugins](./barcode_index.md).
### Activation
This plugin is an *optional* plugin, and must be enabled in the InvenTree admin center.
### Supported Formats
The following barcode formats are supported:
| Format | Example | Notes |
| --- | --- | --- |
| 2D barcode (e.g. DataMatrix) | `[)>␞06␝K123␝1PLM358␝Q10␞␄` | Fields separated by GS / RS characters (ISO/IEC 15434 / ECIA). The `1P` field is used if present, otherwise the `P` field. |
| Prefixed MPN | `1PLM358` or `PLM358` | A single field with a `1P` or `P` prefix, followed by the MPN. |
| Raw MPN | `LM358` | The barcode data is the MPN itself. |
For a single prefixed field, both the MPN with the prefix removed *and* the raw barcode data are checked. For example, `PIC16F84A` matches a manufacturer part with MPN `PIC16F84A`.
### Matching Rules
- The MPN must match *exactly*.
- A match is only returned if exactly *one* manufacturer part matches. If the same MPN exists for multiple manufacturers, no match is returned.
- The user must have permission to view manufacturer parts.
### Priority
This plugin has a low [barcode priority](../mixins/barcode.md#barcode-priority), and is only used if no other barcode plugin is able to match the scanned barcode. A match from a supplier plugin (which may also identify the supplier part) is always preferred.
!!! warning "Supplier Plugin Configuration"
If a supplier barcode plugin is enabled, but no supplier is configured for it (and none can be automatically determined), that plugin may match *any* standard 2D barcode by MPN alone. Ensure that each enabled supplier plugin has the correct supplier selected.
This plugin does not support receiving items against a purchase order, as a manufacturer part number alone cannot identify the supplier.
+1
View File
@@ -17,6 +17,7 @@ The following builtin plugins are available in InvenTree:
| Barcodes | [DigiKey](./barcode_digikey.md) | DigiKey barcode support | No |
| Barcodes | [InvenTree Barcode](./inventree_barcode.md) | Internal barcode support | Yes |
| Barcodes | [LCSC](./barcode_lcsc.md) | LCSC barcode support | No |
| Barcodes | [Manufacturer](./barcode_manufacturer.md) | Fallback barcode support for manufacturer part numbers | No |
| Barcodes | [Mouser](./barcode_mouser.md) | Mouser barcode support | No |
| Barcodes | [TME](./barcode_tme.md) | TME barcode support | No |
| Data Export | [BOM Exporter](./bom_exporter.md) | Custom [exporter](../mixins/export.md) for BOM data | Yes |
+13
View File
@@ -24,6 +24,19 @@ POST {
}
```
### Barcode Priority
When a barcode is scanned, the active barcode plugins are queried in order of their `BARCODE_PRIORITY` attribute (highest first), and the first plugin to return a successful match is used. Plugins with equal priority are queried in the order they are loaded.
The default priority is `0`. A plugin which should only be used as a *fallback* (when no other plugin can match the barcode) should set a negative priority:
```python
class MyFallbackBarcodePlugin(BarcodeMixin, InvenTreePlugin):
BARCODE_PRIORITY = -10
```
A plugin which should take precedence over the builtin plugins can set a positive priority. Note that a higher priority plugin may prevent other plugins (including the builtin InvenTree barcode plugin) from matching a barcode.
### Builtin Plugin
The InvenTree server includes a builtin barcode plugin which can generate and decode the QR codes. This plugin is enabled by default.