diff --git a/InvenTree/plugin/samples/integration/locate.py b/InvenTree/plugin/samples/integration/locate.py new file mode 100644 index 0000000000..37645da771 --- /dev/null +++ b/InvenTree/plugin/samples/integration/locate.py @@ -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!")