From fdf214626c5ba077ea580ccd5a85f2e8643db4c9 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 7 May 2018 23:40:17 +1000 Subject: [PATCH] Further assorted updates What, you need more commit details?! Pah --- InvenTree/part/templates/part/stock.html | 16 ++++------- InvenTree/static/script/inventree/stock.js | 2 ++ InvenTree/stock/models.py | 17 ++++++++++++ InvenTree/stock/templates/stock/item.html | 2 +- InvenTree/stock/templates/stock/location.html | 27 ++++++++----------- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index 3f6f41d1c6..48b16a0f99 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -18,7 +18,6 @@ @@ -111,19 +110,14 @@ return false; }); - $("#multi-item-delete").click(function() { - - var items = selectedStock(); - - deleteStockItems(items, {}); - - return false; - }); - $("#multi-item-stocktake").click(function() { var items = selectedStock(); - countStockItems(items, {}); + countStockItems(items, { + success: function() { + $("#stock-table").bootstrapTable('refresh'); + } + }); return false; }); diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js index 7a1bb3f8d6..56f457b53e 100644 --- a/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/static/script/inventree/stock.js @@ -125,6 +125,8 @@ function countStockItems(items, options) { ] }); + $(modal).find('#stocktake-table').bootstrapTable('checkAll'); + $(modal).on('click', '#modal-form-submit', function() { var selections = $(modal).find('#stocktake-table').bootstrapTable('getSelections'); diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 0c55f452c7..892067b4bb 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -57,6 +57,23 @@ class StockItem(models.Model): If a serial number is assigned, then StockItem cannot have a quantity other than 1 """ + def save(self, *args, **kwargs): + if not self.pk: + add_note = True + else: + add_note = False + + super(StockItem, self).save(*args, **kwargs) + + if add_note: + # This StockItem is being saved for the first time + self.add_transaction_note( + 'Created stock item', + None, + system=True + ) + + def clean(self): # The 'supplier_part' field must point to the same part! diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 890b868d13..9b964ec63b 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -118,7 +118,7 @@ {% if track.notes %}
{{ track.notes }} {% endif %} - {{ track.date }} - {{ track.user }} + {{ track.date }}{% if track.user %} - {{ track.user }}{% endif %} {% endfor %} diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 43b7cebb8f..defb0c1828 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -49,7 +49,6 @@ @@ -127,20 +126,11 @@ var items = selectedStock(); moveStockItems(items, - { - success: function() { - $("#stock-table").bootstrapTable('refresh'); - } - }); - - return false; - }); - - $("#multi-item-delete").click(function() { - - var items = selectedStock(); - - deleteStockItems(items, {}); + { + success: function() { + $("#stock-table").bootstrapTable('refresh'); + } + }); return false; }); @@ -148,7 +138,12 @@ $("#multi-item-stocktake").click(function() { var items = selectedStock(); - countStockItems(items, {}); + countStockItems(items, + { + success: function() { + $("#stock-table").bootstrapTable('refresh'); + } + }); return false; });