2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Added example for barcode plugin (#5670)

* Added example for barcode plugin

* Add some words in stock location reports

* Correct error in link

* Correct error in link

* Typo in link

* Style in code example
This commit is contained in:
Michael
2023-10-17 01:24:05 +02:00
committed by GitHub
parent d98b1bb2c7
commit f409cd6894
4 changed files with 50 additions and 0 deletions

View File

@ -23,3 +23,35 @@ POST {
barcode_data: "[(>someBarcodeDataWhichThePluginKnowsHowToDealWith"
}
```
### Example
Please find below a very simple example that is executed each time a barcode is scanned.
```python
from django.utils.translation import gettext_lazy as _
from InvenTree.models import InvenTreeBarcodeMixin
from plugin import InvenTreePlugin
from plugin.mixins import BarcodeMixin
class InvenTreeBarcodePlugin(BarcodeMixin, InvenTreePlugin):
NAME = "MyBarcode"
TITLE = "My Barcodes"
DESCRIPTION = "support for barcodes"
VERSION = "0.0.1"
AUTHOR = "Michael"
status = 0
def scan(self, barcode_data):
self.status = self.status+1
print('Started barcode plugin', self.status)
print(barcode_data)
response = {}
return response
```
To try it just copy the file to src/InvenTree/plugins and restart the server. Open the scan barcode window and start to scan codes or type in text manually. Each time the timeout is hit the plugin will execute and printout the result. The timeout can be changed in settings->Barcode Support->Barcode Input Delay.