Update javascript rendering in BOM table

This commit is contained in:
Oliver Walters 2022-04-21 23:58:12 +10:00
parent fa2510c42f
commit ec34d23bfc

View File

@ -807,22 +807,23 @@ function loadBomTable(table, options={}) {
var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`;
// Calculate total "available" (unallocated) quantity
var total = row.available_stock;
var base_stock = row.available_stock;
var substitute_stock = row.available_substitute_stock || 0;
var variant_stock = row.allow_variants ? (row.available_variant_stock || 0) : 0;
var available_stock = base_stock + substitute_stock + variant_stock;
total += (row.available_substitute_stock || 0);
total += (row.available_variant_stock || 0);
var text = `${available_stock}`;
var text = `${total}`;
if (total <= 0) {
if (available_stock <= 0) {
text = `<span class='badge rounded-pill bg-danger'>{% trans "No Stock Available" %}</span>`;
} else {
var extra = '';
if (row.available_substitute_stock && row.available_variant_stock) {
if ((substitute_stock > 0) && (variant_stock > 0)) {
extra = '{% trans "Includes variant and substitute stock" %}';
} else if (row.available_variant_stock) {
} else if (variant_stock > 0) {
extra = '{% trans "Includes variant stock" %}';
} else if (row.available_substitute_stock) {
} else if (substitute_stock > 0) {
extra = '{% trans "Includes substitute stock" %}';
}