2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 19:15:41 +00:00

Display count badges in sidenav tree

Uses the 'tags' parameter as according to the docs - https://github.com/jonmiles/bootstrap-treeview

- Part
- Stock
This commit is contained in:
Oliver Walters
2019-05-09 20:30:23 +10:00
parent 2c5bb6b126
commit 45223fb607
5 changed files with 35 additions and 7 deletions

View File

@ -48,6 +48,18 @@ class StockLocation(InvenTreeTree):
}
)
@property
def stock_item_count(self):
""" Return the number of StockItem objects which live in or under this category
"""
return len(StockItem.objects.filter(location__in=self.getUniqueChildren()))
@property
def item_count(self):
return self.stock_item_count
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
def before_delete_stock_location(sender, instance, using, **kwargs):