mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-16 01:36:29 +00:00
[Feature] Scrap Build Outputs (#4800)
* Update docs for status codes * Adds API endpoint for scrapping individual build outputs * Support 'buildorder' reference in stock tracking history * Add page for build output documentation * Build docs * Add example build order process to docs * remove debug statement * JS lint cleanup * Add migration file for stock status * Add unit tests for build output scrapping * Increment API version * bug fix
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
{% load status_codes %}
|
||||
|
||||
/* globals
|
||||
attachSelect,
|
||||
closeModal,
|
||||
constructField,
|
||||
constructFormBody,
|
||||
getFormFieldValue,
|
||||
@@ -18,12 +16,6 @@
|
||||
loadTableFilters,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeOptionsList,
|
||||
modalEnable,
|
||||
modalSetContent,
|
||||
modalSetTitle,
|
||||
modalSubmit,
|
||||
openModal,
|
||||
renderLink,
|
||||
scanItemsIntoLocation,
|
||||
showAlertDialog,
|
||||
@@ -54,7 +46,6 @@
|
||||
serializeStockItem,
|
||||
stockItemFields,
|
||||
stockLocationFields,
|
||||
stockStatusCodes,
|
||||
uninstallStockItem,
|
||||
*/
|
||||
|
||||
@@ -603,22 +594,6 @@ function findStockItemBySerialNumber(part_id) {
|
||||
}
|
||||
|
||||
|
||||
/* Stock API functions
|
||||
* Requires api.js to be loaded first
|
||||
*/
|
||||
|
||||
function stockStatusCodes() {
|
||||
return [
|
||||
{% for code in StockStatus.list %}
|
||||
{
|
||||
key: {{ code.key }},
|
||||
text: '{{ code.value }}',
|
||||
},
|
||||
{% endfor %}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign multiple stock items to a customer
|
||||
*/
|
||||
@@ -2261,93 +2236,6 @@ function loadStockTable(table, options) {
|
||||
orderParts(parts, {});
|
||||
});
|
||||
|
||||
$('#multi-item-set-status').click(function() {
|
||||
// Select and set the STATUS field for selected stock items
|
||||
var selections = getTableData(table);
|
||||
|
||||
// Select stock status
|
||||
var modal = '#modal-form';
|
||||
|
||||
var status_list = makeOptionsList(
|
||||
stockStatusCodes(),
|
||||
function(item) {
|
||||
return item.text;
|
||||
},
|
||||
function(item) {
|
||||
return item.key;
|
||||
}
|
||||
);
|
||||
|
||||
// Add an empty option at the start of the list
|
||||
status_list.unshift('<option value="">---------</option>');
|
||||
|
||||
// Construct form
|
||||
var html = `
|
||||
<form method='post' action='' class='js-modal-form' enctype='multipart/form-data'>
|
||||
<div class='form-group'>
|
||||
<label class='control-label requiredField' for='id_status'>
|
||||
{% trans "Stock Status" %}
|
||||
</label>
|
||||
<div class='controls'>
|
||||
<select id='id_status' class='select form-control' name='label'>
|
||||
${status_list}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
openModal({
|
||||
modal: modal,
|
||||
});
|
||||
|
||||
modalEnable(modal, true);
|
||||
modalSetTitle(modal, '{% trans "Set Stock Status" %}');
|
||||
modalSetContent(modal, html);
|
||||
|
||||
attachSelect(modal);
|
||||
|
||||
modalSubmit(modal, function() {
|
||||
var label = $(modal).find('#id_status');
|
||||
|
||||
var status_code = label.val();
|
||||
|
||||
closeModal(modal);
|
||||
|
||||
if (!status_code) {
|
||||
showAlertDialog(
|
||||
'{% trans "Select Status Code" %}',
|
||||
'{% trans "Status code must be selected" %}'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var requests = [];
|
||||
|
||||
selections.forEach(function(item) {
|
||||
var url = `/api/stock/${item.pk}/`;
|
||||
|
||||
requests.push(
|
||||
inventreePut(
|
||||
url,
|
||||
{
|
||||
status: status_code,
|
||||
},
|
||||
{
|
||||
method: 'PATCH',
|
||||
success: function() {
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
$.when.apply($, requests).done(function() {
|
||||
$(table).bootstrapTable('refresh');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#multi-item-delete').click(function() {
|
||||
var selections = getTableData(table);
|
||||
|
||||
@@ -2697,11 +2585,24 @@ function loadStockTrackingTable(table, options) {
|
||||
html += '</td></tr>';
|
||||
}
|
||||
|
||||
// BuildOrder Information
|
||||
if (details.buildorder) {
|
||||
html += `<tr><th>{% trans "Build Order" %}</th>`;
|
||||
html += `<td>`;
|
||||
|
||||
if (details.buildorder_detail) {
|
||||
html += renderLink(
|
||||
details.buildorder_detail.reference,
|
||||
`/build/${details.buildorder}/`
|
||||
);
|
||||
} else {
|
||||
html += `<i>{% trans "Build order no longer exists" %}</i>`;
|
||||
}
|
||||
}
|
||||
|
||||
// PurchaseOrder Information
|
||||
if (details.purchaseorder) {
|
||||
|
||||
html += `<tr><th>{% trans "Purchase Order" %}</th>`;
|
||||
|
||||
html += '<td>';
|
||||
|
||||
if (details.purchaseorder_detail) {
|
||||
|
Reference in New Issue
Block a user