{% load i18n %} {% load inventree_extras %} {% load status_codes %} /* globals attachSelect, closeModal, constructField, constructFormBody, getFormFieldValue, global_settings, handleFormErrors, imageHoverIcon, inventreeGet, inventreePut, launchModalForm, linkButtonsToSelection, loadTableFilters, makeIconBadge, makeIconButton, makeOptionsList, modalEnable, modalSetContent, modalSetTitle, modalSubmit, openModal, renderLink, scanItemsIntoLocation, showAlertDialog, setupFilterList, showApiError, stockStatusDisplay, */ /* exported assignStockToCustomer, createNewStockItem, createStockLocation, deleteStockItem, deleteStockLocation, duplicateStockItem, editStockItem, editStockLocation, findStockItemBySerialNumber, installStockItem, loadInstalledInTable, loadStockLocationTable, loadStockTable, loadStockTestResultsTable, loadStockTrackingTable, loadTableFilters, mergeStockItems, removeStockRow, serializeStockItem, stockItemFields, stockLocationFields, stockStatusCodes, uninstallStockItem, */ /* * Launches a modal form to serialize a particular StockItem */ function serializeStockItem(pk, options={}) { var url = `/api/stock/${pk}/serialize/`; options.method = 'POST'; options.title = '{% trans "Serialize Stock Item" %}'; options.fields = { quantity: {}, serial_numbers: { icon: 'fa-hashtag', }, destination: { icon: 'fa-sitemap', filters: { structural: false, } }, notes: {}, }; if (options.part) { // Work out the next available serial number inventreeGet(`{% url "api-part-list" %}${options.part}/serial-numbers/`, {}, { success: function(data) { if (data.next) { options.fields.serial_numbers.placeholder = `{% trans "Next available serial number" %}: ${data.next}`; } else if (data.latest) { options.fields.serial_numbers.placeholder = `{% trans "Latest serial number" %}: ${data.latest}`; } }, async: false, }); } options.confirm = true; options.confirmMessage = '{% trans "Confirm Stock Serialization" %}'; constructForm(url, options); } function stockLocationFields(options={}) { var fields = { parent: { help_text: '{% trans "Parent stock location" %}', required: false, }, name: {}, description: {}, owner: {}, structural: {}, external: {}, icon: { help_text: `{% trans "Icon (optional) - Explore all available icons on" %} Font Awesome.`, placeholder: 'fas fa-box', }, }; if (options.parent) { fields.parent.value = options.parent; } if (!global_settings.STOCK_OWNERSHIP_CONTROL) { delete fields['owner']; } return fields; } /* * Launch an API form to edit a stock location */ function editStockLocation(pk, options={}) { var url = `/api/stock/location/${pk}/`; options.fields = stockLocationFields(options); options.title = '{% trans "Edit Stock Location" %}'; constructForm(url, options); } /* * Launch an API form to create a new stock location */ function createStockLocation(options={}) { var url = '{% url "api-location-list" %}'; options.method = 'POST'; options.fields = stockLocationFields(options); options.title = '{% trans "New Stock Location" %}'; options.persist = true; options.persistMessage = '{% trans "Create another location after this one" %}'; options.successMessage = '{% trans "Stock location created" %}'; constructForm(url, options); } /* * Launch an API form to delete a StockLocation */ function deleteStockLocation(pk, options={}) { var url = `/api/stock/location/${pk}/`; var html = `
{% trans "Part" %} | {% trans "Stock Item" %} | {% trans "Location" %} | |
---|---|---|---|
${thumbnail} ${part.full_name} |
${quantity}
|
${location} | ${buttons} |
{% trans "Part" %} | {% trans "Stock Item" %} | {% trans "Location" %} | |
---|---|---|---|
${thumbnail} ${part.full_name} |
${quantity}
|
${location} | ${buttons} |
{% trans "Part" %} | {% trans "Stock" %} | {% trans "Location" %} | ${actionTitle || ''} | |
---|---|---|---|---|
${thumb} ${item.part_detail.full_name} | ${quantity}${status} | ${location} |
${actionInput}
|
${buttons} |
{% trans "Part" %} | `; if (details.part_detail) { html += renderLink(details.part_detail.full_name, `/part/${details.part}/`); } else { html += `{% trans "Part information unavailable" %}`; } html += ` |
---|---|
{% trans "Location" %} | `; html += ''; if (details.location_detail) { // A valid location is provided html += renderLink( details.location_detail.pathstring, details.location_detail.url, ); } else { // An invalid location (may have been deleted?) html += `{% trans "Location no longer exists" %}`; } html += ' |
{% trans "Purchase Order" %} | `; html += ''; if (details.purchaseorder_detail) { html += renderLink( details.purchaseorder_detail.reference, `/order/purchase-order/${details.purchaseorder}/` ); } else { html += `{% trans "Purchase order no longer exists" %}`; } html += ' |
{% trans "Sales Order" %} | `; html += ''; if (details.salesorder_detail) { html += renderLink( details.salesorder_detail.reference, `/order/sales-order/${details.salesorder}` ); } else { html += `{% trans "Sales Order no longer exists" %}`; } html += ` |
{% trans "Return Order" %} | `; html += ''; if (details.returnorder_detail) { html += renderLink( details.returnorder_detail.reference, `/order/return-order/${details.returnorder}/` ); } else { html += `{% trans "Return Order no longer exists" %}`; } html += ` |
{% trans "Customer" %}`; html += ' | '; if (details.customer_detail) { html += renderLink( details.customer_detail.name, details.customer_detail.url ); } else { html += `{% trans "Customer no longer exists" %}`; } html += ' |
{% trans "Stock Item" %}'; html += ' | '; if (details.stockitem_detail) { html += renderLink( details.stockitem, `/stock/item/${details.stockitem}/` ); } else { html += `{% trans "Stock item no longer exists" %}`; } html += ' |
{% trans "Status" %}`; html += ' | '; html += stockStatusDisplay(details.status); html += ' |
{% trans "Added" %} | '; html += `${details.added} | `; html += '
{% trans "Removed" %} | '; html += `${details.removed} | `; html += '
{% trans "Quantity" %} | '; html += `${details.quantity} | `; html += '