2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Merge remote-tracking branch 'inventree/master' into build-fixes

# Conflicts:
#	InvenTree/InvenTree/urls.py
#	InvenTree/locale/de/LC_MESSAGES/django.mo
#	InvenTree/locale/de/LC_MESSAGES/django.po
#	InvenTree/locale/en/LC_MESSAGES/django.po
#	InvenTree/locale/es/LC_MESSAGES/django.po
#	InvenTree/part/templates/part/bom.html
#	InvenTree/templates/js/build.js
#	InvenTree/templates/js/table_filters.js
#	InvenTree/templates/stock_table.html
#	tasks.py
This commit is contained in:
Oliver Walters
2020-10-28 22:24:09 +11:00
27 changed files with 1520 additions and 1298 deletions

View File

@ -440,4 +440,86 @@ function loadBomTable(table, options) {
);
});
}
}
function loadUsedInTable(table, options) {
/* Load a table which displays all the parts that the given part is used in.
*/
var params = {
sub_part: options.part_id,
ordering: 'name',
}
if (options.part_detail) {
params.part_detail = true;
}
if (options.sub_part_detail) {
params.sub_part_detail = true;
}
var filters = {};
if (!options.disableFilters) {
filters = loadTableFilters("usedin");
}
for (var key in params) {
filters[key] = params[key];
}
setupFilterList("usedin", $(table));
// Columns to display in the table
var cols = [
{
field: 'pk',
title: 'ID',
visible: false,
switchable: false,
},
{
field: 'part_detail.full_name',
title: '{% trans "Part" %}',
sortable: true,
formatter: function(value, row, index, field) {
var link = `/part/${row.part}/bom/`;
var html = imageHoverIcon(row.part_detail.thumbnail) + renderLink(row.part_detail.full_name, link);
if (!row.part_detail.active) {
html += "<span class='label label-warning' style='float: right;'>{% trans 'INACTIVE' %}</span>";
}
return html;
}
},
{
field: 'part_detail.description',
title: '{% trans "Description" %}',
sortable: true,
},
{
sortable: true,
field: 'quantity',
title: '{% trans "Uses" %}',
formatter: function(value, row, index, field) {
return parseFloat(value);
},
}
];
// Load the table
$(table).inventreeTable({
url: "{% url 'api-bom-list' %}",
formatNoMatches: function() {
return '{% trans "No matching parts found" %}';
},
columns: cols,
showColumns: true,
sortable: true,
serach: true,
queryParams: filters,
original: params,
});
}

View File

@ -14,7 +14,7 @@ function getAvailableTableFilters(tableKey) {
// Filters for Bill of Materials table
if (tableKey == "bom") {
return {
trackable: {
sub_part_trackable: {
type: 'bool',
title: '{% trans "Trackable Part" %}'
},
@ -25,6 +25,16 @@ function getAvailableTableFilters(tableKey) {
};
}
// Filters for the "used in" table
if (tableKey == 'usedin') {
return {
'part_active': {
type: 'bool',
title: '{% trans "Active" %}',
},
};
}
// Filters for the "customer stock" table (really a subset of "stock")
if (tableKey == "customerstock") {
return {