mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Pass list of selected stock items to the view
This commit is contained in:
parent
f4a052ee2b
commit
72dc75512b
@ -550,6 +550,24 @@ function loadStockTable(table, options) {
|
|||||||
|
|
||||||
$("#multi-item-move").click(function() {
|
$("#multi-item-move").click(function() {
|
||||||
|
|
||||||
|
var items = $('#stock-table').bootstrapTable('getSelections');
|
||||||
|
|
||||||
|
var stock = [];
|
||||||
|
|
||||||
|
items.forEach(function(item) {
|
||||||
|
stock.push(item.pk);
|
||||||
|
});
|
||||||
|
|
||||||
|
launchModalForm("/stock/move/",
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
stock: stock,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
var items = $("#stock-table").bootstrapTable('getSelections');
|
var items = $("#stock-table").bootstrapTable('getSelections');
|
||||||
|
|
||||||
moveStockItems(items,
|
moveStockItems(items,
|
||||||
@ -560,6 +578,7 @@ function loadStockTable(table, options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,9 +132,27 @@ class StockItemMoveMultiple(AjaxView, FormMixin):
|
|||||||
ajax_form_title = 'Move Stock'
|
ajax_form_title = 'Move Stock'
|
||||||
form_class = MoveStockItemForm
|
form_class = MoveStockItemForm
|
||||||
|
|
||||||
|
def get_items(self, item_list):
|
||||||
|
""" Return list of stock items. """
|
||||||
|
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for pk in item_list:
|
||||||
|
try:
|
||||||
|
items.append(StockItem.objects.get(pk=pk))
|
||||||
|
except StockItem.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
|
||||||
|
item_list = request.GET.getlist('stock[]')
|
||||||
|
|
||||||
|
items = self.get_items(item_list)
|
||||||
|
|
||||||
|
print(items)
|
||||||
|
|
||||||
return self.renderJsonResponse(request, self.form_class())
|
return self.renderJsonResponse(request, self.form_class())
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user