From 3b6ef3f00834654604d71ebd7aa7e9346b368818 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 8 May 2018 22:07:24 +1000 Subject: [PATCH] Added stocktake / add / remove actions to StockItemDetail page --- InvenTree/part/templates/part/category.html | 13 +++++- InvenTree/stock/templates/stock/item.html | 40 ++++++++++++++----- .../stock/templates/stock/stock_app_base.html | 6 +++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 74a76e7da2..5b172f1b5e 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -48,7 +48,10 @@ {% endblock %} - +{% block js_load %} +{{ block.super }} + +{% endblock %} {% block js_ready %} {{ block.super }} @@ -165,6 +168,14 @@ title: 'Stock', searchable: false, sortable: true, + formatter: function(value, row, index, field) { + if (value) { + return renderLink(value, row.url + 'stock/'); + } + else { + return ''; + } + } } ], url: "{% url 'api-part-list' %}", diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 8abb54eab2..6b8738d4ef 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -14,12 +14,14 @@ @@ -128,7 +130,6 @@ {% endif %} {% endblock %} - {% block js_ready %} {{ block.super }} $("#stock-edit").click(function () { @@ -148,12 +149,31 @@ }); }); + function itemAdjust(action) { + adjustStock({ + query: { + pk: {{ item.id }}, + }, + action: action, + success: function() { + location.reload(); + } + }); + } + $("#stock-stocktake").click(function() { - launchModalForm( - "{% url 'stock-item-stocktake' item.id %}", - { - reload: true - }); + itemAdjust('stocktake'); + return false; + }); + + $('#stock-remove').click(function() { + itemAdjust('remove'); + return false; + }); + + $('#stock-add').click(function() { + itemAdjust('add'); + return false; }); {% endif %} diff --git a/InvenTree/stock/templates/stock/stock_app_base.html b/InvenTree/stock/templates/stock/stock_app_base.html index 5afe8e44dc..6071499863 100644 --- a/InvenTree/stock/templates/stock/stock_app_base.html +++ b/InvenTree/stock/templates/stock/stock_app_base.html @@ -13,6 +13,12 @@ {% endif %} {% endblock %} +{% block js_load %} +{{ block.super }} + + +{% endblock %} + {% block js_ready %} initSideNav(); {{ block.super }}