mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Sales order variant stock (#5415)
* Annotate available variant stock to SalesOrderLine serializer * Filter variant stock by: - active = True - salable = True * Add 'salable' filter to StockList API * Filter available stock in sales order table: - Must be salable - Must be active * Update table display * Bump API version
This commit is contained in:
@ -1308,6 +1308,8 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) {
|
||||
part_detail: true,
|
||||
location_detail: true,
|
||||
available: true,
|
||||
salable: true,
|
||||
active: true,
|
||||
},
|
||||
model: 'stockitem',
|
||||
required: true,
|
||||
@ -1881,17 +1883,20 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
field: 'stock',
|
||||
title: '{% trans "Available Stock" %}',
|
||||
formatter: function(value, row) {
|
||||
var available = row.available_stock;
|
||||
var required = Math.max(row.quantity - row.allocated - row.shipped, 0);
|
||||
|
||||
var html = '';
|
||||
let available = row.available_stock + row.available_variant_stock;
|
||||
let required = Math.max(row.quantity - row.allocated - row.shipped, 0);
|
||||
|
||||
let html = '';
|
||||
|
||||
if (available > 0) {
|
||||
var url = `/part/${row.part}/?display=part-stock`;
|
||||
let url = `/part/${row.part}/?display=part-stock`;
|
||||
|
||||
var text = available;
|
||||
html = renderLink(available, url);
|
||||
|
||||
html = renderLink(text, url);
|
||||
if (row.available_variant_stock && row.available_variant_stock > 0) {
|
||||
html += makeIconBadge('fa-info-circle icon-blue', '{% trans "Includes variant stock" %}');
|
||||
}
|
||||
} else {
|
||||
html += `<span class='badge rounded-pill bg-danger'>{% trans "No Stock Available" %}</span>`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user