diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html
index 7370a10db6..839ffe4233 100644
--- a/InvenTree/part/templates/part/category.html
+++ b/InvenTree/part/templates/part/category.html
@@ -334,18 +334,8 @@
});
$("#cat-create").click(function() {
-
- var fields = categoryFields();
-
- {% if category %}
- fields.parent.value = {{ category.pk }};
- {% endif %}
-
- constructForm('{% url "api-part-category-list" %}', {
- fields: fields,
- method: 'POST',
- title: '{% trans "Create Part Category" %}',
- follow: true,
+ createPartCategory({
+ {% if category %}parent: {{ category.pk }},{% endif %}
});
});
diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js
index d656ccc77b..b470cb2758 100644
--- a/InvenTree/templates/js/translated/forms.js
+++ b/InvenTree/templates/js/translated/forms.js
@@ -730,7 +730,7 @@ function insertPersistButton(options) {
var html = `
-
+
`;
diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js
index 30ac5400cd..7780783c4f 100644
--- a/InvenTree/templates/js/translated/part.js
+++ b/InvenTree/templates/js/translated/part.js
@@ -20,6 +20,7 @@
/* exported
createPart,
+ createPartCategory,
deletePart,
deletePartCategory,
duplicateBom,
@@ -253,8 +254,8 @@ function partFields(options={}) {
/*
* Construct a set of fields for a PartCategory intance
*/
-function categoryFields() {
- return {
+function categoryFields(options={}) {
+ let fields = {
parent: {
help_text: '{% trans "Parent part category" %}',
required: false,
@@ -276,6 +277,28 @@ function categoryFields() {
placeholder: 'fas fa-tag',
},
};
+
+ if (options.parent) {
+ fields.parent.value = options.parent;
+ }
+
+ return fields;
+}
+
+
+// Create a PartCategory via the API
+function createPartCategory(options={}) {
+ let fields = categoryFields(options);
+
+ constructForm('{% url "api-part-category-list" %}', {
+ fields: fields,
+ method: 'POST',
+ title: '{% trans "Create Part Category" %}',
+ follow: true,
+ persist: true,
+ persistMessage: '{% trans "Create new category after this one" %}',
+ successMessage: '{% trans "Part category created" %}'
+ });
}
@@ -349,7 +372,7 @@ function createPart(options={}) {
fields: partFields(options),
groups: partGroups(),
title: '{% trans "Create Part" %}',
- reloadFormAfterSuccess: true,
+ persist: true,
persistMessage: '{% trans "Create another part after this one" %}',
successMessage: '{% trans "Part created successfully" %}',
onSuccess: function(data) {
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index dcc8d88e59..765a18f67c 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -159,6 +159,9 @@ function createStockLocation(options={}) {
options.method = 'POST';
options.fields = stockLocationFields(options);
options.title = '{% trans "New Stock Location" %}';
+ options.persist = true;
+ options.persistMessage = '{% trans "Create another location after this one" %}';
+ options.successMessage = '{% trans "Stock location created" %}';
constructForm(url, options);
}
@@ -473,6 +476,10 @@ function createNewStockItem(options={}) {
options.create = true;
+ options.persist = true;
+ options.persistMessage = '{% trans "Create another item after this one" %}';
+ options.successMessage = '{% trans "Stock item created" %}';
+
options.fields = stockItemFields(options);
options.groups = stockItemGroups(options);