mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Add unallocated quantity to StockItem renderer (#4425)
* add unallocated quantity to StockItem renderer * introduce parameter to switch between total quantity and available quantity
This commit is contained in:
parent
71db557d3b
commit
e9a1b57941
@ -2296,6 +2296,7 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
render_part_detail: true,
|
render_part_detail: true,
|
||||||
render_location_detail: true,
|
render_location_detail: true,
|
||||||
render_pk: false,
|
render_pk: false,
|
||||||
|
render_available_quantity: true,
|
||||||
auto_fill: true,
|
auto_fill: true,
|
||||||
auto_fill_filters: auto_fill_filters,
|
auto_fill_filters: auto_fill_filters,
|
||||||
onSelect: function(data, field, opts) {
|
onSelect: function(data, field, opts) {
|
||||||
|
@ -111,6 +111,12 @@ function renderStockItem(name, data, parameters={}, options={}) {
|
|||||||
location_detail = ` <small>- (<em>${data.location_detail.name}</em>)</small>`;
|
location_detail = ` <small>- (<em>${data.location_detail.name}</em>)</small>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var render_available_quantity = false;
|
||||||
|
|
||||||
|
if ('render_available_quantity' in parameters) {
|
||||||
|
render_available_quantity = parameters['render_available_quantity'];
|
||||||
|
}
|
||||||
|
|
||||||
var stock_detail = '';
|
var stock_detail = '';
|
||||||
|
|
||||||
if (data.quantity == 0) {
|
if (data.quantity == 0) {
|
||||||
@ -119,7 +125,12 @@ function renderStockItem(name, data, parameters={}, options={}) {
|
|||||||
if (data.serial && data.quantity == 1) {
|
if (data.serial && data.quantity == 1) {
|
||||||
stock_detail = `{% trans "Serial Number" %}: ${data.serial}`;
|
stock_detail = `{% trans "Serial Number" %}: ${data.serial}`;
|
||||||
} else {
|
} else {
|
||||||
stock_detail = `{% trans "Quantity" %}: ${data.quantity}`;
|
if (render_available_quantity) {
|
||||||
|
var available = data.quantity - data.allocated;
|
||||||
|
stock_detail = `{% trans "Available" %}: ${available}`;
|
||||||
|
} else {
|
||||||
|
stock_detail = `{% trans "Quantity" %}: ${data.quantity}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.batch) {
|
if (data.batch) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user