From bf4ffb8b0b61755ac0ec51b70006ab51d721c84b Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 8 May 2018 22:41:52 +1000 Subject: [PATCH] Add part stocktake to Stock Location page(s) --- InvenTree/static/script/tables.js | 10 ++----- InvenTree/stock/models.py | 5 ++-- InvenTree/stock/templates/stock/location.html | 30 ++++++++++++++----- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/InvenTree/static/script/tables.js b/InvenTree/static/script/tables.js index 86195ad45a..1510f48cbe 100644 --- a/InvenTree/static/script/tables.js +++ b/InvenTree/static/script/tables.js @@ -7,15 +7,11 @@ function deleteButton(url, text='Delete') { } function renderLink(text, url) { - if (text && url) { - return '' + text + ''; - } - else if (text) { + if (text === '' || url === '') { return text; } - else { - return ''; - } + + return '' + text + ''; } diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 3533b185cb..926fb71473 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -194,8 +194,6 @@ class StockItem(models.Model): @property def in_stock(self): - if self.quantity == 0: - return False if self.belongs_to or self.customer: return False @@ -284,6 +282,9 @@ class StockItem(models.Model): """ Remove items from stock """ + if self.quantity == 0: + return + quantity = int(quantity) if quantity <= 0 or self.infinite: diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index b285af85a8..15e84a88a1 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -47,6 +47,8 @@ @@ -130,16 +132,28 @@ return false; }); - $("#multi-item-stocktake").click(function() { - var items = selectedStock(); + function _stock(action) { + adjustStock({ + action: action, + items: selectedStock(), + success: function() { + $('#stock-table').bootstrapTable('refresh'); + } + }) + } - countStockItems(items, - { - success: function() { - $("#stock-table").bootstrapTable('refresh'); - } - }); + $('#multi-item-stocktake').click(function() { + _stock('stocktake'); + return false; + }); + $('#multi-item-remove').click(function() { + _stock('remove'); + return false; + }); + + $('#multi-item-add').click(function() { + _stock('add'); return false; });