mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 19:15:41 +00:00
@ -6,6 +6,7 @@ from django_filters.rest_framework import FilterSet, DjangoFilterBackend
|
||||
from django_filters import NumberFilter
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.urls import reverse
|
||||
from django.db.models import Q
|
||||
|
||||
from .models import StockLocation, StockItem
|
||||
@ -27,6 +28,10 @@ class StockCategoryTree(TreeSerializer):
|
||||
title = 'Stock'
|
||||
model = StockLocation
|
||||
|
||||
@property
|
||||
def root_url(self):
|
||||
return reverse('stock-index')
|
||||
|
||||
|
||||
class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
""" API detail endpoint for Stock object
|
||||
|
@ -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):
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="navigation">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href='#' id='toggle-stock-tree'><b>+</b></a></li>
|
||||
<li><a href='#' title='Toggle Stock Tree' id='toggle-stock-tree'><b><span class='glyphicon glyphicon-small glyphicon-th-list'></span></b></a></li>
|
||||
<li class="breadcrumb-item{% if location is None %} active" aria-current="page{% endif %}"><a href="/stock/">Stock</a></li>
|
||||
{% if location %}
|
||||
{% for path_item in location.parentpath %}
|
||||
|
@ -33,7 +33,12 @@ InvenTree | Stock
|
||||
initSideNav();
|
||||
{{ block.super }}
|
||||
loadTree("{% url 'api-stock-tree' %}",
|
||||
"#stock-tree");
|
||||
"#stock-tree",
|
||||
{
|
||||
name: 'stock',
|
||||
selected: 'elab',
|
||||
}
|
||||
);
|
||||
|
||||
$("#toggle-stock-tree").click(function() {
|
||||
toggleSideNav("#sidenav");
|
||||
|
Reference in New Issue
Block a user