mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Bug fix
- Turns out 'item_count' was actually used for something (that I wrote... recently...)
This commit is contained in:
parent
b7d3bbd836
commit
150c68e65b
@ -43,7 +43,7 @@ class TreeSerializer(views.APIView):
|
|||||||
'pk': item.id,
|
'pk': item.id,
|
||||||
'text': item.name,
|
'text': item.name,
|
||||||
'href': item.get_absolute_url(),
|
'href': item.get_absolute_url(),
|
||||||
'tags': [item.stock_item_count],
|
'tags': [item.item_count],
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.has_children:
|
if item.has_children:
|
||||||
@ -66,7 +66,7 @@ class TreeSerializer(views.APIView):
|
|||||||
|
|
||||||
for item in top_items:
|
for item in top_items:
|
||||||
nodes.append(self.itemToJson(item))
|
nodes.append(self.itemToJson(item))
|
||||||
top_count += item.stock_item_count
|
top_count += item.item_count
|
||||||
|
|
||||||
top = {
|
top = {
|
||||||
'pk': None,
|
'pk': None,
|
||||||
|
@ -55,6 +55,13 @@ class StockLocation(InvenTreeTree):
|
|||||||
|
|
||||||
return StockItem.objects.filter(location__in=self.getUniqueChildren()).count()
|
return StockItem.objects.filter(location__in=self.getUniqueChildren()).count()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def item_count(self):
|
||||||
|
""" Simply returns the number of stock items in this location.
|
||||||
|
Required for tree view serializer.
|
||||||
|
"""
|
||||||
|
return self.stock_item_count
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
|
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
|
||||||
def before_delete_stock_location(sender, instance, using, **kwargs):
|
def before_delete_stock_location(sender, instance, using, **kwargs):
|
||||||
|
@ -79,7 +79,7 @@ class StockTest(TestCase):
|
|||||||
|
|
||||||
# Drawer 3 should have three stock items
|
# Drawer 3 should have three stock items
|
||||||
self.assertEqual(self.drawer3.stock_items.count(), 3)
|
self.assertEqual(self.drawer3.stock_items.count(), 3)
|
||||||
self.assertEqual(self.drawer3.stock_item_count, 3)
|
self.assertEqual(self.drawer3.item_count, 3)
|
||||||
|
|
||||||
def test_stock_count(self):
|
def test_stock_count(self):
|
||||||
part = Part.objects.get(pk=1)
|
part = Part.objects.get(pk=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user