mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
* Refactoring supplier barcode support - Add a set of standard field name strings - Map from custom fields to standard fields - Helper functions for returning common field data - Updated unit tests * Update unit tests * Fix unit test * Add more unit tests' * Improve error messages
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""The DigiKeyPlugin is meant to integrate the DigiKey API into Inventree.
|
|
|
|
This plugin can currently only match DigiKey barcodes to supplier parts.
|
|
"""
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from plugin import InvenTreePlugin
|
|
from plugin.mixins import SettingsMixin, SupplierBarcodeMixin
|
|
|
|
|
|
class DigiKeyPlugin(SupplierBarcodeMixin, SettingsMixin, InvenTreePlugin):
|
|
"""Plugin to integrate the DigiKey API into Inventree."""
|
|
|
|
NAME = "DigiKeyPlugin"
|
|
TITLE = _("Supplier Integration - DigiKey")
|
|
DESCRIPTION = _("Provides support for scanning DigiKey barcodes")
|
|
VERSION = "1.0.0"
|
|
AUTHOR = _("InvenTree contributors")
|
|
|
|
DEFAULT_SUPPLIER_NAME = "DigiKey"
|
|
|
|
SETTINGS = {
|
|
"SUPPLIER_ID": {
|
|
"name": _("Supplier"),
|
|
"description": _("The Supplier which acts as 'DigiKey'"),
|
|
"model": "company.company",
|
|
}
|
|
}
|
|
|
|
def extract_barcode_fields(self, barcode_data) -> dict[str, str]:
|
|
"""Extract barcode fields from a DigiKey plugin"""
|
|
|
|
return self.parse_ecia_barcode2d(barcode_data)
|