2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +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

@ -3,7 +3,9 @@
{% if roles.stock.change %}
<div id='attachment-buttons'>
<div class='btn-group'>
<button type='button' class='btn btn-success' id='new-attachment'>{% trans "Add Attachment" %}</button>
<button type='button' class='btn btn-success' id='new-attachment'>
<span class='fas fa-plus-circle'></span> {% trans "Add Attachment" %}
</button>
</div>
</div>
{% endif %}

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 {

View File

@ -3,11 +3,15 @@
<div id='button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
<div class='btn-group'>
<button class='btn btn-default' id='stock-export' title='{% trans "Export Stock Information" %}'><span class='fas fa-file-download'></span> {% trans "Export" %}</button>
<button class='btn btn-default' id='stock-export' title='{% trans "Export Stock Information" %}'>
<span class='fas fa-file-download'></span> {% trans "Export" %}
</button>
{% if read_only %}
{% else %}
{% if roles.stock.add %}
<button class="btn btn-success" id='item-create'><span class='fas fa-plus-circle'></span> {% trans "New Stock Item" %}</button>
<button class="btn btn-success" id='item-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Stock Item" %}
</button>
{% endif %}
{% if roles.stock.change or roles.stock.delete %}
<div class="btn-group">
@ -35,4 +39,4 @@
</div>
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='stock-table'>
</table>
</table>