mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add optional display of part stock quantity in forms
This commit is contained in:
parent
54d770927a
commit
166af3592d
@ -242,6 +242,13 @@
|
||||
border-color: var(--label-red);
|
||||
}
|
||||
|
||||
.label-form {
|
||||
margin: 2px;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.label-red {
|
||||
background: var(--label-red);
|
||||
}
|
||||
|
@ -648,7 +648,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'validator': bool,
|
||||
},
|
||||
|
||||
# TODO: Remove this setting in future, new API forms make this not useful
|
||||
'PART_SHOW_QUANTITY_IN_FORMS': {
|
||||
'name': _('Show Quantity in Forms'),
|
||||
'description': _('Display available part quantity in some forms'),
|
||||
|
@ -159,7 +159,24 @@ function renderPart(name, data, parameters, options) {
|
||||
html += ` - <i>${data.description}</i>`;
|
||||
}
|
||||
|
||||
html += `<span class='float-right'><small>{% trans "Part ID" %}: ${data.pk}</small></span>`;
|
||||
var stock = '';
|
||||
|
||||
// Display available part quantity
|
||||
if (global_settings.PART_SHOW_QUANTITY_IN_FORMS) {
|
||||
if (data.in_stock == 0) {
|
||||
stock = `<span class='label-form label-red'>{% trans "No Stock" %}</span>`;
|
||||
} else {
|
||||
stock = `<span class='label-form label-green'>{% trans "In Stock" %}: ${data.in_stock}</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
html += `
|
||||
<span class='float-right'>
|
||||
<small>
|
||||
${stock}
|
||||
{% trans "Part ID" %}: ${data.pk}
|
||||
</small>
|
||||
</span>`;
|
||||
|
||||
return html;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user