diff --git a/InvenTree/templates/js/bom.html b/InvenTree/templates/js/bom.html
index ceb8977c04..122b1b7ba8 100644
--- a/InvenTree/templates/js/bom.html
+++ b/InvenTree/templates/js/bom.html
@@ -280,7 +280,9 @@ function loadBomTable(table, options) {
params.sub_part_detail = true;
}
- function requestSubItems(part_pk) {
+ // Function to request BOM data for sub-items
+ // This function may be called recursively for multi-level BOMs
+ function requestSubItems(bom_pk, part_pk) {
inventreeGet(
options.bom_url,
@@ -291,10 +293,17 @@ function loadBomTable(table, options) {
{
success: function(response) {
for (var idx = 0; idx < response.length; idx++) {
- response[idx].parentId = part_pk;
+
+ response[idx].parentId = bom_pk;
+
+ if (response[idx].sub_part_detail.assembly) {
+ requestSubItems(response[idx].pk, response[idx].sub_part)
+ }
}
table.bootstrapTable('append', response);
+
+ table.treegrid('collapseAll');
},
error: function() {
console.log('Error requesting BOM for part=' + part_pk);
@@ -303,13 +312,14 @@ function loadBomTable(table, options) {
)
}
- table.bootstrapTable({
+ table.inventreeTable({
treeEnable: true,
rootParentId: options.parent_id,
- idField: 'sub_part',
+ idField: 'pk',
uniqueId: 'pk',
- parentIdField: 'part',
+ parentIdField: 'parentId',
treeShowField: 'sub_part',
+ showColumns: true,
sortable: true,
search: true,
rowStyle: function(row, index) {
@@ -351,7 +361,7 @@ function loadBomTable(table, options) {
table.bootstrapTable('updateRow', idx, row, true);
if (row.sub_part_detail.assembly) {
- requestSubItems(row.sub_part);
+ requestSubItems(row.pk, row.sub_part);
}
}
},