From d56fed321122b8577412f7b7a62484f19c3a6b2e Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 9 Mar 2022 10:34:47 +1100 Subject: [PATCH] Fixes for "duplicate stock item" form - Redirect to the new stock item - Display a success message --- InvenTree/stock/templates/stock/item_base.html | 4 +--- InvenTree/templates/js/translated/stock.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index f023989887..7dc06664e1 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -462,9 +462,7 @@ $("#print-label").click(function() { {% if roles.stock.change %} $("#stock-duplicate").click(function() { // Duplicate a stock item - duplicateStockItem({{ item.pk }}, { - follow: true, - }); + duplicateStockItem({{ item.pk }}, {}); }); $('#stock-edit').click(function() { diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index dcca969a28..067aab9cae 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -294,7 +294,17 @@ function stockItemGroups(options={}) { */ function duplicateStockItem(pk, options) { - // First, we need the StockItem informatino + // If no "success" function provided, add a default + if (!options.onSuccess) { + options.onSuccess = function(response) { + + showAlertOrCache('{% trans "Stock item duplicated" %}', true, {style: 'success'}); + + window.location.href = `/stock/item/${response.pk}/`; + } + } + + // First, we need the StockItem information inventreeGet(`/api/stock/${pk}/`, {}, { success: function(data) {