2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Merge pull request #2725 from SchrodingersGat/duplicate-stock-item-success

Fixes for "duplicate stock item" form
This commit is contained in:
Oliver 2022-03-09 11:21:55 +11:00 committed by GitHub
commit 7f888923c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -462,9 +462,7 @@ $("#print-label").click(function() {
{% if roles.stock.change %} {% if roles.stock.change %}
$("#stock-duplicate").click(function() { $("#stock-duplicate").click(function() {
// Duplicate a stock item // Duplicate a stock item
duplicateStockItem({{ item.pk }}, { duplicateStockItem({{ item.pk }}, {});
follow: true,
});
}); });
$('#stock-edit').click(function() { $('#stock-edit').click(function() {

View File

@ -294,7 +294,17 @@ function stockItemGroups(options={}) {
*/ */
function duplicateStockItem(pk, 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}/`, {}, { inventreeGet(`/api/stock/${pk}/`, {}, {
success: function(data) { success: function(data) {