mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Build consume stock (#4817)
* Adds "consumed_by" field to the StockItem model. - Points to a BuildOrder instance which "consumed" this stock - Marks item as unavailable - Allows filtering against build order * Allow API filtering * Adds table of "consumed stock items" to build order page * Update stock table to show "consumed by" stock status * Add "consumed_by" link to stock item detail * Optionally add 'buildorder' details to installStockItem method * Update methodology for completing a build item - Instead of deleting stock, mark as "consumed by" * Fix history entry for splitting stock * Bug fix * track "consumed_by" field for tracked items also * Update build docs * Update allocation documentation * Update terminology.md * Unit test updates * Fix conflicting migrations * revert change
This commit is contained in:
@ -160,7 +160,6 @@ loadStockTable($('#table-recently-updated-stock'), {
|
||||
limit: {% settings_value "STOCK_RECENT_COUNT" user=request.user %},
|
||||
},
|
||||
name: 'recently-updated-stock',
|
||||
grouping: false,
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
|
@ -156,7 +156,6 @@
|
||||
|
||||
loadStockTable($('#table-stock'), {
|
||||
filterKey: 'stocksearch',
|
||||
url: "{% url 'api-stock-list' %}",
|
||||
params: {
|
||||
original_search: search_text,
|
||||
part_detail: true,
|
||||
|
@ -671,7 +671,11 @@ function scrapBuildOutputs(build_id, outputs, options={}) {
|
||||
method: 'POST',
|
||||
preFormContent: html,
|
||||
fields: {
|
||||
location: {},
|
||||
location: {
|
||||
filters: {
|
||||
structural: false,
|
||||
}
|
||||
},
|
||||
notes: {},
|
||||
discard_allocations: {},
|
||||
},
|
||||
|
@ -1617,26 +1617,29 @@ function loadStockTestResultsTable(table, options) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function to display a "location" of a StockItem.
|
||||
*
|
||||
* Complicating factors: A StockItem may not actually *be* in a location!
|
||||
* - Could be at a customer
|
||||
* - Could be installed in another stock item
|
||||
* - Could be assigned to a sales order
|
||||
* - Could be currently in production!
|
||||
*
|
||||
* So, instead of being naive, we'll check!
|
||||
*/
|
||||
function locationDetail(row, showLink=true) {
|
||||
/*
|
||||
* Function to display a "location" of a StockItem.
|
||||
*
|
||||
* Complicating factors: A StockItem may not actually *be* in a location!
|
||||
* - Could be at a customer
|
||||
* - Could be installed in another stock item
|
||||
* - Could be assigned to a sales order
|
||||
* - Could be currently in production!
|
||||
*
|
||||
* So, instead of being naive, we'll check!
|
||||
*/
|
||||
|
||||
// Display text
|
||||
var text = '';
|
||||
let text = '';
|
||||
|
||||
// URL (optional)
|
||||
var url = '';
|
||||
let url = '';
|
||||
|
||||
if (row.is_building && row.build) {
|
||||
if (row.consumed_by) {
|
||||
text = '{% trans "Consumed by build order" %}';
|
||||
url = `/build/${row.consumed_by}/`;
|
||||
} else if (row.is_building && row.build) {
|
||||
// StockItem is currently being built!
|
||||
text = '{% trans "In production" %}';
|
||||
url = `/build/${row.build}/`;
|
||||
@ -1827,6 +1830,8 @@ function loadStockTable(table, options) {
|
||||
}
|
||||
} else if (row.belongs_to) {
|
||||
html += makeIconBadge('fa-box', '{% trans "Stock item has been installed in another item" %}');
|
||||
} else if (row.consumed_by) {
|
||||
html += makeIconBadge('fa-tools', '{% trans "Stock item has been consumed by a build order" %}');
|
||||
}
|
||||
|
||||
if (row.expired) {
|
||||
@ -1836,13 +1841,11 @@ function loadStockTable(table, options) {
|
||||
}
|
||||
|
||||
// Special stock status codes
|
||||
|
||||
// REJECTED
|
||||
if (row.status == {{ StockStatus.REJECTED }}) {
|
||||
if (row.status == stockCodes.REJECTED.key) {
|
||||
html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}');
|
||||
} else if (row.status == {{ StockStatus.LOST }}) {
|
||||
} else if (row.status == stockCodes.LOST.key) {
|
||||
html += makeIconBadge('fa-question-circle', '{% trans "Stock item is lost" %}');
|
||||
} else if (row.status == {{ StockStatus.DESTROYED }}) {
|
||||
} else if (row.status == stockCodes.DESTROYED.key) {
|
||||
html += makeIconBadge('fa-skull-crossbones', '{% trans "Stock item is destroyed" %}');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user