2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Toot toot - it's the refactor tractor!

- New function for launching a CreateStockItem form
- Wraps up the previous code improvements into a single function
- Oh, the ease!
This commit is contained in:
Oliver Walters
2020-08-27 00:08:02 +10:00
parent 4be1b2928b
commit 146dae6d43
5 changed files with 79 additions and 109 deletions

View File

@ -320,15 +320,12 @@ $("#print-label").click(function() {
});
$("#stock-duplicate").click(function() {
launchModalForm(
"{% url 'stock-item-create' %}",
{
follow: true,
data: {
copy: {{ item.id }},
},
createNewStockItem({
follow: true,
data: {
copy: {{ item.id }},
}
);
});
});
$("#stock-edit").click(function () {

View File

@ -204,59 +204,13 @@
{% endif %}
$('#item-create').click(function () {
launchModalForm("{% url 'stock-item-create' %}",
{
follow: true,
data: {
{% if location %}
location: {{ location.id }}
{% endif %}
},
callback: [
{
field: 'part',
action: function(value) {
reloadFieldOptions(
'supplier_part',
{
url: "{% url 'api-supplier-part-list' %}",
params: {
part: value,
pretty: true,
},
text: function(item) {
return item.pretty_name;
}
}
)
}
},
],
secondary: [
{
field: 'part',
label: 'New Part',
title: 'Create New Part',
url: "{% url 'part-create' %}",
},
{
field: 'supplier_part',
label: 'New Supplier Part',
title: 'Create new Supplier Part',
url: "{% url 'supplier-part-create' %}"
},
{
field: 'location',
label: 'New Location',
title: 'Create New Location',
url: "{% url 'stock-location-create' %}",
}
]
});
return false;
createNewStockItem({
data: {
{% if location %}
location: {{ location.id }}
{% endif %}
}
});
});
loadStockTable($("#stock-table"), {