feat: Add local barcode plugin
This commit is contained in:
parent
73b34ff7b0
commit
f30620a8a2
5 changed files with 29 additions and 0 deletions
1
Makefile
1
Makefile
|
|
@ -3,6 +3,7 @@ COMPOSE_CMD ?= docker compose
|
||||||
DOCKER_HOST ?= unix:///run/docker.sock
|
DOCKER_HOST ?= unix:///run/docker.sock
|
||||||
COMPOSE := DOCKER_HOST=$(DOCKER_HOST) $(COMPOSE_CMD)
|
COMPOSE := DOCKER_HOST=$(DOCKER_HOST) $(COMPOSE_CMD)
|
||||||
|
|
||||||
|
.PHONY: psql
|
||||||
psql:
|
psql:
|
||||||
$(COMPOSE) exec inventree-db sh -c 'psql $$POSTGRES_USER $$POSTGRES_DB'
|
$(COMPOSE) exec inventree-db sh -c 'psql $$POSTGRES_USER $$POSTGRES_DB'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
# Data volume must map to /home/inventree/data
|
# Data volume must map to /home/inventree/data
|
||||||
- ${INVENTREE_EXT_VOLUME}:/home/inventree/data:z
|
- ${INVENTREE_EXT_VOLUME}:/home/inventree/data:z
|
||||||
|
- ./plugins.txt:/home/inventree/data/plugins.txt:ro,z
|
||||||
|
- ./plugins:/home/inventree/plugins:ro,z
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Background worker process handles long-running or periodic tasks
|
# Background worker process handles long-running or periodic tasks
|
||||||
|
|
|
||||||
1
plugins.txt
Normal file
1
plugins.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
inventree-brother-plugin
|
||||||
0
plugins/__init__.py
Normal file
0
plugins/__init__.py
Normal file
25
plugins/ctbk_barcode.py
Normal file
25
plugins/ctbk_barcode.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
from plugin import InvenTreePlugin
|
||||||
|
from plugin.mixins import BarcodeMixin
|
||||||
|
from part.models import Part
|
||||||
|
import structlog
|
||||||
|
|
||||||
|
logger = structlog.get_logger("ctbk.barcode")
|
||||||
|
|
||||||
|
|
||||||
|
class CtbkBarcodePlugin(BarcodeMixin, InvenTreePlugin):
|
||||||
|
TITLE = "CTBK IPN Barcode Plugin"
|
||||||
|
NAME = "ctbk-ipn-barcode-plugin"
|
||||||
|
DESCRIPTION = "Supports the CTBK IPN format directly in barcodes"
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
AUTHOR = "kleines Filmröllchen"
|
||||||
|
|
||||||
|
def scan(self, barcode_data):
|
||||||
|
if barcode_data.startswith("963e5440-"):
|
||||||
|
try:
|
||||||
|
instance = Part.objects.get(IPN=barcode_data.strip())
|
||||||
|
label = Part.barcode_model_type()
|
||||||
|
|
||||||
|
return {label: instance.format_matched_response()}
|
||||||
|
except Part.DoesNotExist:
|
||||||
|
logger.error("could not find a part for barcode %s", barcode_data)
|
||||||
|
pass
|
||||||
Loading…
Add table
Add a link
Reference in a new issue