mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +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:
@ -734,4 +734,60 @@ function loadStockTrackingTable(table, options) {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function createNewStockItem(options) {
|
||||
/* Launch a modal form to create a new stock item.
|
||||
*
|
||||
* This is really just a helper function which calls launchModalForm,
|
||||
* but it does get called a lot, so here we are ...
|
||||
*/
|
||||
|
||||
// Add in some funky options
|
||||
|
||||
options.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;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
options.secondary = [
|
||||
{
|
||||
field: 'part',
|
||||
label: '{% trans "New Part" %}',
|
||||
title: '{% trans "Create New Part" %}',
|
||||
url: "{% url 'part-create' %}",
|
||||
},
|
||||
{
|
||||
field: 'supplier_part',
|
||||
label: '{% trans "New Supplier Part" %}',
|
||||
title: '{% trans "Create new Supplier Part" %}',
|
||||
url: "{% url 'supplier-part-create' %}"
|
||||
},
|
||||
{
|
||||
field: 'location',
|
||||
label: '{% trans "New Location" %}',
|
||||
title: '{% trans "Create New Location" %}',
|
||||
url: "{% url 'stock-location-create' %}",
|
||||
},
|
||||
];
|
||||
|
||||
launchModalForm("{% url 'stock-item-create' %}", options);
|
||||
}
|
Reference in New Issue
Block a user