diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js
index 5a5a628b9c..4bca89e4a0 100644
--- a/InvenTree/static/script/inventree/stock.js
+++ b/InvenTree/static/script/inventree/stock.js
@@ -1,5 +1,5 @@
-function moveStock(rows, options) {
+function moveStockItems(items, options) {
var modal = '#modal-form';
@@ -7,7 +7,7 @@ function moveStock(rows, options) {
modal = options.modal;
}
- if (rows.length == 0) {
+ if (items.length == 0) {
alert('No stock items selected');
return;
}
@@ -33,54 +33,75 @@ function moveStock(rows, options) {
}
getStockLocations({},
- {
- success: function(response) {
- openModal(modal);
- modalSetTitle(modal, "Move " + rows.length + " stock items");
- modalSetButtonText(modal, "Move");
+ {
+ success: function(response) {
+ openModal(modal);
+ modalSetTitle(modal, "Move " + items.length + " stock items");
+ modalSetButtonText(modal, "Move");
- // Extact part row info
- var parts = [];
+ // Extact part row info
+ var parts = [];
- var html = "Select new location:
\n";
+ var html = "Select new location:
\n";
- html += "
";
+
+ html += "The following stock items will be moved:
\n";
+
+ for (i = 0; i < items.length; i++) {
+ parts.push(items[i].pk);
+
+ html += "- " + items[i].quantity + " × " + items[i].part.name;
+
+ if (items[i].location) {
+ html += " (" + items[i].location.name + ")";
+ }
+
+ html += "
\n";
+ }
+
+ html += "
\n";
+
+ modalSetContent(modal, html);
+ attachSelect(modal);
+
+ $(modal).on('click', '#modal-form-submit', function() {
+ var locId = $(modal).find("#stock-location").val();
+
+ doMove(locId, parts);
+ });
+ },
+ error: function(error) {
+ alert('Error getting stock locations:\n' + error.error);
+ }
+ });
+}
+
+function deleteStockItems(items, options) {
+
+ var modal = '#modal-delete';
+
+ if ('modal' in options) {
+ modal = options.modal;
+ }
+
+ if (items.length == 0) {
+ alert('No stock items selected');
+ return;
+ }
+
+ function doDelete(parts) {
+ //TODO
+ }
+
+ openModal(modal);
+ modalSetTitle(modal, 'Delete ' + items.length + ' stock items');
}
\ No newline at end of file
diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py
index 33c9f4dddf..0ca86315f9 100644
--- a/InvenTree/stock/models.py
+++ b/InvenTree/stock/models.py
@@ -166,6 +166,10 @@ class StockItem(models.Model):
infinite = models.BooleanField(default=False)
+ def can_delete(self):
+ # TODO - Return FALSE if this item cannot be deleted!
+ return True
+
@property
def in_stock(self):
if self.quantity == 0:
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html
index 12f11c03e9..d5df1a0715 100644
--- a/InvenTree/stock/templates/stock/location.html
+++ b/InvenTree/stock/templates/stock/location.html
@@ -126,19 +126,21 @@
var items = selectedStock();
- moveStock(items,
+ moveStockItems(items,
{
success: function() {
$("#stock-table").bootstrapTable('refresh');
}
});
+
+ return false;
});
$("#multi-item-delete").click(function() {
var items = selectedStock();
- alert('Deleting ' + items.length + ' items');
+ deleteStockItems(items, {});
return false;
});