mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds sample plugin for locating items
This commit is contained in:
parent
59c747841c
commit
172705cc3b
34
InvenTree/plugin/samples/integration/locate.py
Normal file
34
InvenTree/plugin/samples/integration/locate.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
Sample plugin for locating stock items / locations.
|
||||||
|
|
||||||
|
Note: This plugin does not *actually* locate anything!
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from plugin import IntegrationPluginBase
|
||||||
|
from plugin.mixins import LocateMixin
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger('inventree')
|
||||||
|
|
||||||
|
|
||||||
|
class SampleLocatePlugin(LocateMixin, IntegrationPluginBase):
|
||||||
|
|
||||||
|
PLUGIN_NAME = "SampleLocatePlugin"
|
||||||
|
PLUGIN_SLUG = "samplelocate",
|
||||||
|
PLUGIN_TITLE = "Sample plugin for locating items"
|
||||||
|
|
||||||
|
VERSION = "0.1"
|
||||||
|
|
||||||
|
def locate_stock_location(self, location_pk):
|
||||||
|
|
||||||
|
from stock.models import StockLocation
|
||||||
|
|
||||||
|
logger.info(f"SampleLocatePlugin attempting to locate location ID {location_pk}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
location = StockLocation.objects.get(pk=location_pk)
|
||||||
|
logger.info(f"Location exists at '{location.pathstring}'")
|
||||||
|
except StockLocation.DoesNotExist:
|
||||||
|
logger.error(f"Location ID {location_pk} does not exist!")
|
Loading…
Reference in New Issue
Block a user