diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 26e48e59fe..d200392084 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -194,8 +194,22 @@ class OrderParts(AjaxView): for item in stock_items: part_ids.add(item.part.id) - print("Parts:", part_ids) + # User has passed a list of part ID values + if 'parts[]' in self.request.GET: + part_id_list = self.request.GET.getlist('parts[]') + + print("Provided list of part:") + print(part_id_list) + + parts = Part.objects.filter( + purchaseable=True, + id__in=part_id_list) + + for part in parts: + part_ids.add(part.id) + + print("Parts:", part_ids) # Create the list of parts for id in part_ids: diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 2d76b08ac9..bbe449d217 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -49,6 +49,7 @@ diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js index 7c933ef303..d56a8d4769 100644 --- a/InvenTree/static/script/inventree/part.js +++ b/InvenTree/static/script/inventree/part.js @@ -192,4 +192,22 @@ function loadPartTable(table, url, options={}) { if (options.buttons) { linkButtonsToSelection($(table), options.buttons); } + + /* Button callbacks for part table buttons */ + + $("#multi-part-order").click(function() { + var selections = $(table).bootstrapTable("getSelections"); + + var parts = []; + + selections.forEach(function(item) { + parts.push(item.pk); + }); + + launchModalForm("/order/purchase-order/order-parts/", { + data: { + parts: parts, + }, + }); + }); } \ No newline at end of file