Add setting for enabeling reports

Fixes #2278
This commit is contained in:
Matthias 2021-11-10 23:54:54 +01:00
parent 4d6189653e
commit bae28e8207
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
11 changed files with 39 additions and 2 deletions

View File

@ -34,6 +34,7 @@ src="{% static 'img/blank_image.png' %}"
{% include "admin_button.html" with url=url %}
{% endif %}
<!-- Printing options -->
{% if report_enabled %}
<div class='btn-group'>
<button id='print-options' title='{% trans "Print actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
<span class='fas fa-print'></span> <span class='caret'></span>
@ -42,6 +43,7 @@ src="{% static 'img/blank_image.png' %}"
<li><a class='dropdown-item' href='#' id='print-build-report'><span class='fas fa-file-pdf'></span> {% trans "Print build order report" %}</a></li>
</ul>
</div>
{% endif %}
<!-- Build actions -->
{% if roles.build.change %}
<div class='btn-group'>
@ -224,9 +226,11 @@ src="{% static 'img/blank_image.png' %}"
{% endif %}
});
{% if report_enabled %}
$('#print-build-report').click(function() {
printBuildReports([{{ build.pk }}]);
});
{% endif %}
$("#build-delete").on('click', function() {
launchModalForm(

View File

@ -27,6 +27,7 @@
<div class='button-toolbar container-fluid' style='float: right;'>
<div class='btn-group' role='group'>
{% if report_enabled %}
<div class='btn-group' role='group'>
<!-- Print actions -->
<button id='build-print-options' class='btn btn-primary dropdown-toggle' data-bs-toggle='dropdown'>
@ -38,6 +39,7 @@
</a></li>
</ul>
</div>
{% endif %}
<!-- Buttons to switch between list and calendar views -->
<button class='btn btn-outline-secondary' type='button' id='view-calendar' title='{% trans "Display calendar view" %}'>
<span class='fas fa-calendar-alt'></span>
@ -181,6 +183,7 @@ loadBuildTable($("#build-table"), {
url: "{% url 'api-build-list' %}",
});
{% if report_enabled %}
$('#multi-build-print').click(function() {
var rows = $("#build-table").bootstrapTable('getSelections');
@ -192,5 +195,6 @@ $('#multi-build-print').click(function() {
printBuildReports(build_ids);
});
{% endif %}
{% endblock %}

View File

@ -768,6 +768,13 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'validator': InvenTree.validators.validate_part_name_format
},
'REPORT_ENABLE': {
'name': _('Enable Reports'),
'description': _('Enable generation of reports'),
'default': False,
'validator': bool,
},
'REPORT_DEBUG_MODE': {
'name': _('Debug Mode'),
'description': _('Generate reports in debug mode (HTML output)'),

View File

@ -29,7 +29,9 @@
<span class='fas fa-print'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu' role='menu'>
{% if report_enabled %}
<li><a class='dropdown-item' href='#' id='print-order-report'><span class='fas fa-file-pdf'></span> {% trans "Print purchase order report" %}</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='export-order'><span class='fas fa-file-download'></span> {% trans "Export order to file" %}</a></li>
</ul>
</div>
@ -169,9 +171,11 @@ $("#place-order").click(function() {
});
{% endif %}
{% if report_enabled %}
$('#print-order-report').click(function() {
printPurchaseOrderReports([{{ order.pk }}]);
});
{% endif %}
$("#edit-order").click(function() {

View File

@ -26,10 +26,11 @@
<div id='table-buttons'>
<div class='button-toolbar container-fluid' style='float: right;'>
<div class='btn-group' role='group'>
{% if report_enabled %}
<button id='order-print' class='btn btn-outline-secondary' title='{% trans "Print Order Reports" %}'>
<span class='fas fa-print'></span>
</button>
{% endif %}
<button class='btn btn-outline-secondary' type='button' id='view-calendar' title='{% trans "Display calendar view" %}'>
<span class='fas fa-calendar-alt'></span>
</button>
@ -169,6 +170,7 @@ $("#view-list").click(function() {
$("#view-calendar").show();
});
{% if report_enabled %}
$("#order-print").click(function() {
var rows = $("#purchase-order-table").bootstrapTable('getSelections');
@ -180,6 +182,7 @@ $("#order-print").click(function() {
printPurchaseOrderReports(orders);
})
{% endif %}
$("#po-create").click(function() {
createPurchaseOrder();

View File

@ -39,7 +39,9 @@ src="{% static 'img/blank_image.png' %}"
<span class='fas fa-print'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu' role='menu'>
{% if report_enabled %}
<li><a class='dropdown-item' href='#' id='print-order-report'><span class='fas fa-file-pdf'></span> {% trans "Print sales order report" %}</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='export-order'><span class='fas fa-file-download'></span> {% trans "Export order to file" %}</a></li>
<!--
<li><a class='dropdown-item' href='#' id='print-packing-list'><span class='fas fa-clipboard-list'></span>{% trans "Print packing list" %}</a></li>
@ -206,9 +208,11 @@ $("#ship-order").click(function() {
});
});
{% if report_enabled %}
$('#print-order-report').click(function() {
printSalesOrderReports([{{ order.pk }}]);
});
{% endif %}
$('#export-order').click(function() {
exportOrder('{% url "so-export" order.id %}');

View File

@ -29,10 +29,11 @@
<div id='table-buttons'>
<div class='button-toolbar container-fluid' style='float: right;'>
<div class='btn-group'>
{% if report_enabled %}
<button id='order-print' class='btn btn-outline-secondary' title='{% trans "Print Order Reports" %}'>
<span class='fas fa-print'></span>
</button>
{% endif %}
<button class='btn btn-outline-secondary' type='button' id='view-calendar' title='{% trans "Display calendar view" %}'>
<span class='fas fa-calendar-alt'></span>
</button>
@ -173,6 +174,7 @@ loadSalesOrderTable("#sales-order-table", {
url: "{% url 'api-so-list' %}",
});
{% if report_enabled %}
$("#order-print").click(function() {
var rows = $("#sales-order-table").bootstrapTable('getSelections');
@ -184,6 +186,7 @@ $("#order-print").click(function() {
printSalesOrderReports(orders);
})
{% endif %}
$("#so-create").click(function() {
createSalesOrder();

View File

@ -164,7 +164,9 @@
<li><a class='dropdown-item' href='#' id='multi-part-category' title='{% trans "Set category" %}'>{% trans "Set Category" %}</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='multi-part-order' title='{% trans "Order parts" %}'>{% trans "Order Parts" %}</a></li>
{% if report_enabled %}
<li><a class='dropdown-item' href='#' id='multi-part-print-label' title='{% trans "Print Labels" %}'>{% trans "Print Labels" %}</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='multi-part-export' title='{% trans "Export" %}'>{% trans "Export Data" %}</a></li>
</ul>
</div>

View File

@ -373,7 +373,9 @@
</button>
<ul class='dropdown-menu' role='menu'>
<li><a class='dropdown-item' href='#' id='download-bom'><span class='fas fa-file-download'></span> {% trans "Export BOM" %}</a></li>
{% if report_enabled %}
<li><a class='dropdown-item' href='#' id='print-bom-report'><span class='fas fa-file-pdf'></span> {% trans "Print BOM Report" %}</a></li>
{% endif %}
</ul>
</div>
<!-- Actions menu -->
@ -766,9 +768,11 @@
);
});
{% if report_enabled %}
$("#print-bom-report").click(function() {
printBomReports([{{ part.pk }}]);
});
{% endif %}
});
// Load the "related parts" tab

View File

@ -12,6 +12,7 @@
<table class='table table-striped table-condensed'>
<tbody>
{% include "InvenTree/settings/setting.html" with key="REPORT_ENABLE" %}
{% include "InvenTree/settings/setting.html" with key="REPORT_DEFAULT_PAGE_SIZE" %}
{% include "InvenTree/settings/setting.html" with key="REPORT_DEBUG_MODE" %}
{% include "InvenTree/settings/setting.html" with key="REPORT_ENABLE_TEST_REPORT" %}

View File

@ -4,6 +4,7 @@
{% settings_value 'BARCODE_ENABLE' as barcodes %}
{% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %}
{% settings_value "REPORT_ENABLE" as report_enabled %}
<!DOCTYPE html>
<html lang="en">