diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index e47ad56783..22015676e9 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -1008,6 +1008,23 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': InvenTree.validators.validate_part_name_format }, + 'LABEL_ENABLE': { + 'name': _('Enable label printing'), + 'description': _('Enable label printing from the web interface'), + 'default': True, + 'validator': bool, + }, + + 'LABEL_DPI': { + 'name': _('Label Image DPI'), + 'description': _('DPI resolution when generating image files to supply to label printing plugins'), + 'default': 300, + 'validator': [ + int, + MinValueValidator(100), + ] + }, + 'REPORT_ENABLE': { 'name': _('Enable Reports'), 'description': _('Enable generation of reports'), @@ -1389,12 +1406,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'default': True, 'validator': bool, }, - 'LABEL_ENABLE': { - 'name': _('Enable label printing'), - 'description': _('Enable label printing from the web interface'), - 'default': True, - 'validator': bool, - }, "LABEL_INLINE": { 'name': _('Inline label display'), diff --git a/InvenTree/plugin/base/label/label.py b/InvenTree/plugin/base/label/label.py index 5baf0ec872..cc0ccadef5 100644 --- a/InvenTree/plugin/base/label/label.py +++ b/InvenTree/plugin/base/label/label.py @@ -8,6 +8,7 @@ from django.utils.translation import gettext_lazy as _ import pdf2image import common.notifications +from common.models import InvenTreeSetting from InvenTree.exceptions import log_error from plugin.registry import registry @@ -36,9 +37,10 @@ def print_label(plugin_slug: str, pdf_data, filename=None, label_instance=None, return # In addition to providing a .pdf image, we'll also provide a .png file + dpi = InvenTreeSetting.get_setting('LABEL_DPI', 300) png_file = pdf2image.convert_from_bytes( pdf_data, - dpi=300, + dpi=dpi, )[0] try: diff --git a/InvenTree/templates/InvenTree/settings/label.html b/InvenTree/templates/InvenTree/settings/label.html new file mode 100644 index 0000000000..7d7dd8a5eb --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/label.html @@ -0,0 +1,20 @@ +{% extends "panel.html" %} +{% load i18n %} +{% load inventree_extras %} + +{% block label %}labels{% endblock %} + +{% block heading %} +{% trans "Label Settings" %} +{% endblock %} + +{% block content %} + + + + {% include "InvenTree/settings/setting.html" with key="LABEL_ENABLE" icon='fa-toggle-on' %} + {% include "InvenTree/settings/setting.html" with key="LABEL_DPI" icon='fa-toggle-on' %} + +
+ +{% endblock %} diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index 96236ec54d..de3a36b9d1 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -33,6 +33,7 @@ {% include "InvenTree/settings/login.html" %} {% include "InvenTree/settings/barcode.html" %} {% include "InvenTree/settings/currencies.html" %} +{% include "InvenTree/settings/label.html" %} {% include "InvenTree/settings/report.html" %} {% include "InvenTree/settings/part.html" %} {% include "InvenTree/settings/category.html" %} diff --git a/InvenTree/templates/InvenTree/settings/sidebar.html b/InvenTree/templates/InvenTree/settings/sidebar.html index 3d06228c15..620c589359 100644 --- a/InvenTree/templates/InvenTree/settings/sidebar.html +++ b/InvenTree/templates/InvenTree/settings/sidebar.html @@ -34,6 +34,8 @@ {% include "sidebar_item.html" with label='barcodes' text=text icon="fa-qrcode" %} {% trans "Currencies" as text %} {% include "sidebar_item.html" with label='currencies' text=text icon="fa-dollar-sign" %} +{% trans "Label Printing" as text %} +{% include "sidebar_item.html" with label='labels' text=text icon='fa-tag' %} {% trans "Reporting" as text %} {% include "sidebar_item.html" with label='reporting' text=text icon="fa-file-pdf" %} {% trans "Parts" as text %} diff --git a/InvenTree/templates/InvenTree/settings/user_labels.html b/InvenTree/templates/InvenTree/settings/user_labels.html index d14db225d4..93c7c0b2bc 100644 --- a/InvenTree/templates/InvenTree/settings/user_labels.html +++ b/InvenTree/templates/InvenTree/settings/user_labels.html @@ -14,7 +14,6 @@
- {% include "InvenTree/settings/setting.html" with key="LABEL_ENABLE" icon='fa-toggle-on' user_setting=True %} {% include "InvenTree/settings/setting.html" with key="LABEL_INLINE" icon='fa-tag' user_setting=True %}
diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 1ae46c34f9..0d47656dd9 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -7,7 +7,7 @@ {% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %} {% settings_value "REPORT_ENABLE" as report_enabled %} {% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %} -{% settings_value "LABEL_ENABLE" with user=user as labels_enabled %} +{% settings_value "LABEL_ENABLE" as labels_enabled %} {% inventree_show_about user as show_about %}