diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py
index 9775883bbd..2aa9f8185e 100644
--- a/InvenTree/InvenTree/urls.py
+++ b/InvenTree/InvenTree/urls.py
@@ -34,8 +34,6 @@ apipatterns = [
urlpatterns = [
- # API URL
- url(r'^api/', include(apipatterns)),
# url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
url(r'^part/', include(part_urls)),
@@ -50,6 +48,8 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
+
+ url(r'^api/', include(apipatterns)),
]
# Static file access
diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py
index 5b2a0f481a..5a8c78c211 100644
--- a/InvenTree/part/serializers.py
+++ b/InvenTree/part/serializers.py
@@ -1,6 +1,33 @@
from rest_framework import serializers
-from .models import Part
+from .models import Part, PartCategory
+
+
+class CategoryBriefSerializer(serializers.ModelSerializer):
+
+ url = serializers.CharField(source='get_absolute_url', read_only=True)
+
+ class Meta:
+ model = PartCategory
+ fields = [
+ 'pk',
+ 'name',
+ 'pathstring',
+ 'url',
+ ]
+
+
+class PartBriefSerializer(serializers.ModelSerializer):
+
+ url = serializers.CharField(source='get_absolute_url', read_only=True)
+
+ class Meta:
+ model = Part
+ fields = [
+ 'pk',
+ 'url',
+ 'name',
+ ]
class PartSerializer(serializers.ModelSerializer):
@@ -8,18 +35,7 @@ class PartSerializer(serializers.ModelSerializer):
Used when displaying all details of a single component.
"""
- def _category_name(self, part):
- if part.category:
- return part.category.name
- return ''
-
- def _category_url(self, part):
- if part.category:
- return part.category.get_absolute_url()
- return ''
-
- category_name = serializers.SerializerMethodField('_category_name')
- category_url = serializers.SerializerMethodField('_category_url')
+ category = CategoryBriefSerializer(many=False, read_only=True)
class Meta:
model = Part
@@ -31,8 +47,6 @@ class PartSerializer(serializers.ModelSerializer):
'URL', # Link to an external URL (optional)
'description',
'category',
- 'category_name',
- 'category_url',
'total_stock',
'available_stock',
'units',
diff --git a/InvenTree/part/templates/part/category_parts.html b/InvenTree/part/templates/part/category_parts.html
index ed87b275ee..3a8c272463 100644
--- a/InvenTree/part/templates/part/category_parts.html
+++ b/InvenTree/part/templates/part/category_parts.html
@@ -40,10 +40,15 @@
{% if category == None %}
{
sortable: true,
- field: 'category_name',
+ field: 'category',
title: 'Category',
formatter: function(value, row, index, field) {
- return renderLink(value, row.category_url)
+ if (row.category) {
+ return renderLink(row.category.name, row.category.url);
+ }
+ else {
+ return '';
+ }
}
},
{% endif %}
diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py
index a9c5c3248a..52b605d651 100644
--- a/InvenTree/stock/serializers.py
+++ b/InvenTree/stock/serializers.py
@@ -2,10 +2,30 @@ from rest_framework import serializers
from .models import StockItem, StockLocation
+from part.serializers import PartBriefSerializer
+
+
+class LocationBriefSerializer(serializers.ModelSerializer):
+
+ url = serializers.CharField(source='get_absolute_url', read_only=True)
+
+ class Meta:
+ model = StockLocation
+ fields = [
+ 'pk',
+ 'name',
+ 'pathstring',
+ 'url',
+ ]
+
class StockItemSerializer(serializers.ModelSerializer):
""" Serializer for a StockItem
"""
+ url = serializers.CharField(source='get_absolute_url', read_only=True)
+
+ part = PartBriefSerializer(many=False, read_only=True)
+ location = LocationBriefSerializer(many=False, read_only=True)
class Meta:
model = StockItem
@@ -16,17 +36,17 @@ class StockItemSerializer(serializers.ModelSerializer):
'supplier_part',
'location',
'in_stock',
- 'belongs_to',
- 'customer',
+ #'belongs_to',
+ #'customer',
'quantity',
'serial',
'batch',
'status',
'notes',
- 'updated',
- 'stocktake_date',
- 'stocktake_user',
- 'review_needed',
+ #'updated',
+ #'stocktake_date',
+ #'stocktake_user',
+ #'review_needed',
]
""" These fields are read-only in this context.
diff --git a/InvenTree/stock/templates/stock/index.html b/InvenTree/stock/templates/stock/index.html
index aba6fe88b7..9665f8c571 100644
--- a/InvenTree/stock/templates/stock/index.html
+++ b/InvenTree/stock/templates/stock/index.html
@@ -9,35 +9,7 @@
{% include "stock/location_list.html" with locations=locations %}
{% endif %}
-
-
-
- Part |
- Location |
- Stock |
- Status |
- Stocktake |
- |
-
-
-
-{% for item in items.all %}
-
- {{ item.part.name }} |
-
- {% if item.location %}
-
- {{ item.location.pathstring }}
-
- {% endif %}
- |
- {{ item.quantity }} |
- {{ item.get_status_display }} |
- {{ item.stocktake_date }} |
- Click |
-
-{% endfor %}
-
+
@@ -60,4 +32,7 @@
follow: true
});
});
+
+ {% include "stock/stock_table.html" %}
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html
index 8327eab1e1..c0e98db2f9 100644
--- a/InvenTree/stock/templates/stock/location.html
+++ b/InvenTree/stock/templates/stock/location.html
@@ -12,8 +12,10 @@
{% include "stock/location_list.html" with locations=location.children %}
{% endif %}
-
Stock Items
-{% include "stock/stock_table.html" with items=location.items %}
+{% if location.has_items %}
+
+{% endif %}
@@ -69,4 +71,7 @@
}
});
});
+
+ {% include 'stock/stock_table.html' with location=location %}
+
{% endblock %}
diff --git a/InvenTree/stock/templates/stock/stock_table.html b/InvenTree/stock/templates/stock/stock_table.html
index d061814a29..d9cb775ac1 100644
--- a/InvenTree/stock/templates/stock/stock_table.html
+++ b/InvenTree/stock/templates/stock/stock_table.html
@@ -1,22 +1,60 @@
-
-
-
- Part |
- Stock |
- Status |
- Stocktake |
- |
-
-
-
-{% for item in items.all %}
-
- {{ item.part.name }} |
- {{ item.quantity }} |
- {{ item.get_status_display }} |
- {{ item.stocktake_date }} |
- Click |
-
-{% endfor %}
-
-
\ No newline at end of file
+$("#stock-table").bootstrapTable({
+ sortable: true,
+ search: true,
+ method: 'get',
+ pagination: true,
+ rememberOrder: true,
+ {% if location %}
+ queryParams: function(p) {
+ return {
+ location: {{ location.id }}
+ }
+ },
+ {% endif %}
+ columns: [
+ {
+ checkbox: true,
+ title: 'Select',
+ searchable: false,
+ },
+ {
+ field: 'pk',
+ title: 'ID',
+ visible: false,
+ },
+ {
+ field: 'part.name',
+ title: 'Part',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ return renderLink(value, row.part.url);
+ }
+ },
+ {% if location == None %}
+ {
+ field: 'location',
+ title: 'Location',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ if (row.location) {
+ return renderLink(row.location.name, row.location.url);
+ }
+ else {
+ return '';
+ }
+ }
+ },
+ {% endif %}
+ {
+ field: 'quantity',
+ title: 'Stock',
+ sortable: true,
+ },
+ {
+ field: 'status',
+ title: 'Status',
+ sortable: true,
+ }
+ ],
+ url: "{% url 'api-stock-list' %}",
+});
\ No newline at end of file