mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Add tests for successful location
- Sample plugin now updates metadata tag
This commit is contained in:
@ -23,7 +23,23 @@ class SampleLocatePlugin(LocateMixin, InvenTreePlugin):
|
||||
SLUG = "samplelocate"
|
||||
TITLE = "Sample plugin for locating items"
|
||||
|
||||
VERSION = "0.1"
|
||||
VERSION = "0.2"
|
||||
|
||||
def locate_stock_item(self, item_pk):
|
||||
|
||||
from stock.models import StockItem
|
||||
|
||||
logger.info(f"SampleLocatePlugin attempting to locate item ID {item_pk}")
|
||||
|
||||
try:
|
||||
item = StockItem.objects.get(pk=item_pk)
|
||||
logger.info(f"StockItem {item_pk} located!")
|
||||
|
||||
# Tag metadata
|
||||
item.set_metadata('located', True)
|
||||
|
||||
except (ValueError, StockItem.DoesNotExist):
|
||||
logger.error(f"StockItem ID {item_pk} does not exist!")
|
||||
|
||||
def locate_stock_location(self, location_pk):
|
||||
|
||||
@ -34,5 +50,9 @@ class SampleLocatePlugin(LocateMixin, InvenTreePlugin):
|
||||
try:
|
||||
location = StockLocation.objects.get(pk=location_pk)
|
||||
logger.info(f"Location exists at '{location.pathstring}'")
|
||||
except StockLocation.DoesNotExist:
|
||||
|
||||
# Tag metadata
|
||||
location.set_metadata('located', True)
|
||||
|
||||
except (ValueError, StockLocation.DoesNotExist):
|
||||
logger.error(f"Location ID {location_pk} does not exist!")
|
||||
|
Reference in New Issue
Block a user