diff --git a/InvenTree/static/script/inventree/api.js b/InvenTree/static/script/inventree/api.js index a2f0e14814..c9b593f3b1 100644 --- a/InvenTree/static/script/inventree/api.js +++ b/InvenTree/static/script/inventree/api.js @@ -23,6 +23,7 @@ function inventreeGet(url, filters={}, options={}) { type: 'GET', data: filters, dataType: 'json', + contentType: 'application/json', success: function(response) { console.log('Success GET data at ' + url); if (options.success) { @@ -62,8 +63,9 @@ function inventreeUpdate(url, data={}, options={}) { }, url: url, type: method, - data: data, + data: JSON.stringify(data), dataType: 'json', + contentType: 'application/json', success: function(response, status) { response['_status_code'] = status; console.log('UPDATE object to ' + url + ' - result = ' + status); diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js index 55e9f2d423..7a1bb3f8d6 100644 --- a/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/static/script/inventree/stock.js @@ -16,7 +16,7 @@ function moveStockItems(items, options) { inventreeUpdate("/api/stock/move/", { location: location, - parts: parts + 'parts[]': parts }, { success: function(response) { @@ -97,8 +97,67 @@ function countStockItems(items, options) { return; } + var tbl = "
"; + openModal(modal); - modalSetTitle(modal, 'Stocktake'); + modalSetTitle(modal, 'Stocktake ' + items.length + ' items'); + + $(modal).find('.modal-form-content').html(tbl); + + $(modal).find('#stocktake-table').bootstrapTable({ + data: items, + columns: [ + { + checkbox: true, + }, + { + field: 'part.name', + title: 'Part', + }, + { + field: 'location.name', + title: 'Location', + }, + { + field: 'quantity', + title: 'Quantity', + } + ] + }); + + $(modal).on('click', '#modal-form-submit', function() { + var selections = $(modal).find('#stocktake-table').bootstrapTable('getSelections'); + + var stocktake = []; + + console.log('Performing stocktake on ' + selections.length + ' items'); + + for (i = 0; i= 0'}) + items.append(item) for item in items: @@ -111,7 +115,7 @@ class StockMove(APIView): if not u'parts[]' in data: raise ValidationError({'parts[]': 'Parts list must be specified'}) - part_list = data.getlist(u'parts[]') + part_list = data.get(u'parts[]') parts = []