Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature to exclude/include consumable price in BOM price range - FR #7603 #7787

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions src/backend/InvenTree/part/templates/part/bom.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,25 @@
{% include "filter_list.html" with id="bom" %}
</div>

<div class="form-check">
<input class="form-check-input" type="checkbox" id="include_consumables_in_bom_pricing" checked>
<label class="form-check-label" for="flexCheckChecked">
{% trans "Include consumables in BOM pricing" %}
</label>
</div>

<table class='table table-bom table-condensed' data-toolbar="#bom-button-toolbar" id='bom-table'>
</table>


<script>
// Add listener to the include consumables in pricing checkbox

document.addEventListener('DOMContentLoaded', function() {
var checkbox = document.getElementById('include_consumables_in_bom_pricing');

checkbox.addEventListener('change', function() {
reloadBootstrapTable('#bom-table');
});
});
</script>
9 changes: 8 additions & 1 deletion src/backend/InvenTree/templates/js/translated/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ function loadBomTable(table, options={}) {
);
},
footerFormatter: function(data) {
// Display overall price range the "footer" of the price_range column
// Display overall price range in the "footer" of the price_range column

var min_price = 0;
var max_price = 0;
Expand All @@ -1118,6 +1118,13 @@ function loadBomTable(table, options={}) {
continue;
}

// check if it is a consumable and add it only if required
var include_consumables_in_pricing = document.getElementById('include_consumables_in_bom_pricing').checked
if(row.consumable && !include_consumables_in_pricing){
continue;
}


// At this point, we have at least *some* information
any_pricing = true;

Expand Down
16 changes: 0 additions & 16 deletions src/backend/InvenTree/templates/js/translated/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1646,22 +1646,6 @@ function addFieldCallbacks(fields, options) {
function addFieldCallback(name, field, options) {
const el = getFormFieldElement(name, options);

if (field.onEdit) {
el.change(function() {

var value = getFormFieldValue(name, field, options);
let onEditHandlers = field.onEdit;

if (!Array.isArray(onEditHandlers)) {
onEditHandlers = [onEditHandlers];
}

for (const onEdit of onEditHandlers) {
onEdit(value, name, field, options);
}
});
}

if(field.onInput){

el.on('input', function(){
Expand Down
Loading