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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.

View File

@ -148,6 +148,7 @@ InvenTree supports the following reporting functionality:
| [Purchase Order Report](./purchase_order.md) | Format a purchase order report |
| [Sales Order Report](./sales_order.md) | Format a sales order report |
| [Return Order Report](./return_order.md) | Format a return order report |
| [Stock Location Report](./stock_location.md) | Format a stock location report |
### Default Reports

View File

@ -0,0 +1,16 @@
---
title: Stock Location Reports
---
## Stock location Reports
You can print a formatted report of a stock location. This makes sense if you have several parts inside one location, e.g. a box that is sent out to a manufacturing partner. Whit a report you can create a box content list.
### Context Variables
You can use all content variables from the [StockLocation](./context_variables.md#stocklocation) object.
### Default Report Template
A default report template is provided out of the box, which can be used as a starting point for developing custom return order report templates.
View the [source code](https://github.com/inventree/InvenTree/blob/master/InvenTree/report/templates/report/inventree_slr_report.html) for the default stock location report template.

View File

@ -140,6 +140,7 @@ nav:
- Sales Order: report/sales_order.md
- Return Order: report/return_order.md
- BOM: report/bom.md
- Stock Location: report/stock_location.md
- Labels:
- Custom Labels: report/labels.md
- Part Labels: report/labels/part_labels.md