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:
@@ -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 %}
|
||||
|
||||
|
Reference in New Issue
Block a user