Fixes for "duplicate stock item" form

- Redirect to the new stock item
- Display a success message
This commit is contained in:
Oliver 2022-03-09 10:34:47 +11:00
parent 8a8fd1b4ba
commit d56fed3211
2 changed files with 12 additions and 4 deletions

View File

@ -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() {

View File

@ -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) {