2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

CreatePart form now uses the API

- Simplify the way category parameter templates are copied
This commit is contained in:
Oliver Walters
2021-08-04 23:27:16 +10:00
parent 2bf3e3ab02
commit b04f22fc53
7 changed files with 74 additions and 227 deletions

View File

@@ -264,25 +264,25 @@
{% if roles.part.add %}
$("#part-create").click(function() {
launchModalForm(
"{% url 'part-create' %}",
{
follow: true,
data: {
{% if category %}
category: {{ category.id }}
{% endif %}
},
secondary: [
{
field: 'default_location',
label: '{% trans "New Location" %}',
title: '{% trans "Create new Stock Location" %}',
url: "{% url 'stock-location-create' %}",
}
]
}
);
var fields = partFields({
create: true,
});
{% if category %}
fields.category.value = {{ category.pk }};
{% endif %}
constructForm('{% url "api-part-list" %}', {
method: 'POST',
fields: fields,
title: '{% trans "Create Part" %}',
onSuccess: function(data) {
// Follow the new part
location.href = `/part/${data.pk}/`;
},
});
});
{% endif %}