From a0e7d37a194804d11076d3de3e7df04673901bc3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 4 Feb 2021 21:15:19 +1100 Subject: [PATCH] Add setting for enabling / disabling test reports --- InvenTree/InvenTree/urls.py | 1 + InvenTree/common/models.py | 7 ++++++ InvenTree/part/templates/part/part_base.html | 1 - .../report/inventree_test_report.html | 1 + .../stock/templates/stock/item_base.html | 8 ++----- InvenTree/stock/templates/stock/location.html | 3 +-- .../templates/InvenTree/settings/report.html | 22 +++++++++++++++++++ .../templates/InvenTree/settings/tabs.html | 3 +++ InvenTree/templates/base.html | 1 + InvenTree/templates/stock_table.html | 2 ++ 10 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 InvenTree/templates/InvenTree/settings/report.html diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 2c56b8eeb1..1df5e83d5d 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -79,6 +79,7 @@ settings_urls = [ url(r'^theme/?', ColorThemeSelectView.as_view(), name='settings-theme'), url(r'^global/?', SettingsView.as_view(template_name='InvenTree/settings/global.html'), name='settings-global'), + url(r'^report/?', SettingsView.as_view(template_name='InvenTree/settings/report.html'), name='settings-report'), url(r'^category/?', SettingCategorySelectView.as_view(), name='settings-category'), url(r'^part/?', SettingsView.as_view(template_name='InvenTree/settings/part.html'), name='settings-part'), url(r'^stock/?', SettingsView.as_view(template_name='InvenTree/settings/stock.html'), name='settings-stock'), diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 053cc12864..a81d06ed25 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -174,6 +174,13 @@ class InvenTreeSetting(models.Model): 'validator': bool, }, + 'REPORT_ENABLE_TEST_REPORT': { + 'name': _('Test Reports'), + 'description': _('Enable generation of test reports'), + 'default': True, + 'validator': bool, + }, + 'STOCK_ENABLE_EXPIRY': { 'name': _('Stock Expiry'), 'description': _('Enable stock expiry functionality'), diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 84eac7e7f4..f35d616a91 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -44,7 +44,6 @@ - {% settings_value 'BARCODE_ENABLE' as barcodes %} {% if barcodes %}
diff --git a/InvenTree/report/templates/report/inventree_test_report.html b/InvenTree/report/templates/report/inventree_test_report.html index 7ac1930632..e076a7919e 100644 --- a/InvenTree/report/templates/report/inventree_test_report.html +++ b/InvenTree/report/templates/report/inventree_test_report.html @@ -61,6 +61,7 @@ content: "{% trans 'Stock Item Test Report' %}";

{{ part.description }}

{{ stock_item.location }}

+

Stock Item ID: {{ stock_item.pk }}

diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index d284a74e98..93d60fb3d1 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -120,7 +120,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
- {% settings_value 'BARCODE_ENABLE' as barcodes %} + {% if barcodes %}
@@ -139,19 +139,15 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% endif %} - {% if item.has_labels or item.has_test_reports %}
- {% endif %} {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 4f8268b037..817b096f74 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -36,8 +36,7 @@ {% endif %} - {% endif %} - {% settings_value 'BARCODE_ENABLE' as barcodes %} + {% endif %} {% if barcodes %} {% if location %} diff --git a/InvenTree/templates/InvenTree/settings/report.html b/InvenTree/templates/InvenTree/settings/report.html new file mode 100644 index 0000000000..0cba8c449b --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/report.html @@ -0,0 +1,22 @@ +{% extends "InvenTree/settings/settings.html" %} +{% load i18n %} +{% load inventree_extras %} + +{% block tabs %} +{% include "InvenTree/settings/tabs.html" with tab='report' %} +{% endblock %} + +{% block subtitle %} +{% trans "Report Settings" %} +{% endblock %} + +{% block settings %} + + + {% include "InvenTree/settings/header.html" %} + + {% include "InvenTree/settings/setting.html" with key="REPORT_ENABLE_TEST_REPORT" %} + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/tabs.html b/InvenTree/templates/InvenTree/settings/tabs.html index ff2bcdb61e..bb660519b8 100644 --- a/InvenTree/templates/InvenTree/settings/tabs.html +++ b/InvenTree/templates/InvenTree/settings/tabs.html @@ -15,6 +15,9 @@
  • {% trans "Global" %}
  • +
  • + {% trans "Report" %} +
  • {% trans "Categories" %} diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index d2b8226982..c1640892de 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -3,6 +3,7 @@ {% load inventree_extras %} {% settings_value 'BARCODE_ENABLE' as barcodes %} +{% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %} diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index 4caf2f59fd..8eff0f4aed 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -38,7 +38,9 @@
    {% if roles.stock.change or roles.stock.delete %}