diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index c5ef3e49eb..8ad09f616b 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -7,6 +7,7 @@ from __future__ import unicode_literals from rest_framework import serializers from InvenTree.serializers import InvenTreeModelSerializer +from stock.serializers import StockItemSerializerBrief from .models import Build, BuildItem @@ -35,7 +36,8 @@ class BuildItemSerializer(InvenTreeModelSerializer): """ Serializes a BuildItem object """ part = serializers.IntegerField(source='stock_item.part.pk', read_only=True) - part_name = serializers.CharField(source='stock_item.part', read_only=True) + part_name = serializers.CharField(source='stock_item.part.name', read_only=True) + stock_item_detail = StockItemSerializerBrief(source='stock_item', read_only=True) class Meta: model = BuildItem @@ -45,5 +47,6 @@ class BuildItemSerializer(InvenTreeModelSerializer): 'part', 'part_name', 'stock_item', + 'stock_item_detail', 'quantity' ] diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 0a746524b3..e4b527097a 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -18,16 +18,45 @@ {{ block.super }} + {% endblock %} {% block js_ready %} {{ block.super }} + function makeInnerTable(pk) { + var table = "
"; + return table; + } + $('#build-table').bootstrapTable({ sortable: true, + detailView: true, + detailFormatter: function(index, row, element) { + return makeInnerTable(row.pk); + }, + onExpandRow: function(index, row, $detail) { + $('#part-table-' + row.pk).bootstrapTable({ + columns: [ + { + field: 'stock_item_detail.location_name', + title: 'Location', + }, + { + field: 'stock_item_detail.quantity', + title: 'Available', + }, + { + field: 'quantity', + title: 'Allocated', + }, + ], + url: "/api/build/item/?build={{ build.pk }}&part=" + row.sub_part, + }); + }, columns: [ { - field: 'sub_part.name', + field: 'sub_part_detail.name', title: 'Part', }, { @@ -36,7 +65,7 @@ { field: 'quantity', title: 'Quantity', - } + }, ], }); diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js index 9396e01772..053355113b 100644 --- a/InvenTree/static/script/inventree/part.js +++ b/InvenTree/static/script/inventree/part.js @@ -15,5 +15,5 @@ function getPartList(filters={}, options={}) { } function getBomList(filters={}, options={}) { - return inventreeGet('/api/part/bom/', filters, options); + return inventreeGet('/api/bom/', filters, options); } \ No newline at end of file diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 0a863aa7f9..a6780faf15 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -47,6 +47,24 @@ class StockItemSerializerBrief(serializers.ModelSerializer): ] +class StockItemSerializerBrief(serializers.ModelSerializer): + """ Brief serializers for a StockItem """ + + location_name = serializers.CharField(source='location', read_only=True) + + class Meta: + model = StockItem + fields = [ + 'pk', + 'uuid', + 'part', + 'supplier_part', + 'location', + 'location_name', + 'quantity', + ] + + class StockItemSerializer(serializers.ModelSerializer): """ Serializer for a StockItem: