mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Label dpi config (#3208)
* Updates for label printing settings: - Make LABEL_ENABLE a global setting - Add LABEL_DPI setting (default = 300) - Add new global settings tab * Use the configured DPI when printing labels
This commit is contained in:
parent
9bd62f986f
commit
d84b67ddf4
@ -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'),
|
||||
|
@ -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:
|
||||
|
20
InvenTree/templates/InvenTree/settings/label.html
Normal file
20
InvenTree/templates/InvenTree/settings/label.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% extends "panel.html" %}
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block label %}labels{% endblock %}
|
||||
|
||||
{% block heading %}
|
||||
{% trans "Label Settings" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table class='table table-striped table-condensed'>
|
||||
<tbody>
|
||||
{% 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' %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -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" %}
|
||||
|
@ -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 %}
|
||||
|
@ -14,7 +14,6 @@
|
||||
<div class='row'>
|
||||
<table class='table table-striped table-condensed'>
|
||||
<tbody>
|
||||
{% 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 %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -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 %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
Loading…
Reference in New Issue
Block a user