mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	| @@ -46,6 +46,7 @@ import InvenTree.ready | |||||||
| import InvenTree.tasks | import InvenTree.tasks | ||||||
| import InvenTree.validators | import InvenTree.validators | ||||||
| import order.validators | import order.validators | ||||||
|  | from plugin import registry | ||||||
|  |  | ||||||
| logger = logging.getLogger('inventree') | logger = logging.getLogger('inventree') | ||||||
|  |  | ||||||
| @@ -1628,6 +1629,15 @@ class InvenTreeSetting(BaseInvenTreeSetting): | |||||||
|             return False |             return False | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def label_printer_options(): | ||||||
|  |     """Build a list of available label printer options.""" | ||||||
|  |     printers = [('', _('No Printer (Export to PDF)'))] | ||||||
|  |     label_printer_plugins = registry.with_mixin('labels') | ||||||
|  |     if label_printer_plugins: | ||||||
|  |         printers.extend([(p.slug, p.name + ' - ' + p.human_name) for p in label_printer_plugins]) | ||||||
|  |     return printers | ||||||
|  |  | ||||||
|  |  | ||||||
| class InvenTreeUserSetting(BaseInvenTreeSetting): | class InvenTreeUserSetting(BaseInvenTreeSetting): | ||||||
|     """An InvenTreeSetting object with a usercontext.""" |     """An InvenTreeSetting object with a usercontext.""" | ||||||
|  |  | ||||||
| @@ -1781,6 +1791,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): | |||||||
|             'validator': bool, |             'validator': bool, | ||||||
|         }, |         }, | ||||||
|  |  | ||||||
|  |         "LABEL_DEFAULT_PRINTER": { | ||||||
|  |             'name': _('Default label printer'), | ||||||
|  |             'description': _('Configure which label printer should be selected by default'), | ||||||
|  |             'default': '', | ||||||
|  |             'choices': label_printer_options | ||||||
|  |         }, | ||||||
|  |  | ||||||
|         "REPORT_INLINE": { |         "REPORT_INLINE": { | ||||||
|             'name': _('Inline report display'), |             'name': _('Inline report display'), | ||||||
|             'description': _('Display PDF reports in the browser, instead of downloading as a file'), |             'description': _('Display PDF reports in the browser, instead of downloading as a file'), | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ | |||||||
|     <table class='table table-striped table-condensed'> |     <table class='table table-striped table-condensed'> | ||||||
|         <tbody> |         <tbody> | ||||||
|             {% include "InvenTree/settings/setting.html" with key="LABEL_INLINE" icon='fa-tag' user_setting=True %} |             {% include "InvenTree/settings/setting.html" with key="LABEL_INLINE" icon='fa-tag' user_setting=True %} | ||||||
|  |             {% include "InvenTree/settings/setting.html" with key="LABEL_DEFAULT_PRINTER" icon='fa-tag' user_setting=True %} | ||||||
|         </tbody> |         </tbody> | ||||||
|     </table> |     </table> | ||||||
| </div> | </div> | ||||||
|   | |||||||
| @@ -262,7 +262,11 @@ function selectLabel(labels, items, options={}) { | |||||||
|         `; |         `; | ||||||
|  |  | ||||||
|         plugins.forEach(function(plugin) { |         plugins.forEach(function(plugin) { | ||||||
|             plugin_selection += `<option value='${plugin.key}' title='${plugin.meta.human_name}'>${plugin.name} - <small>${plugin.meta.human_name}</small></option>`; |             var selected = ''; | ||||||
|  |             if (user_settings['LABEL_DEFAULT_PRINTER'] == plugin.key) { | ||||||
|  |                 selected = ' selected'; | ||||||
|  |             } | ||||||
|  |             plugin_selection += `<option value='${plugin.key}' title='${plugin.meta.human_name}'${selected}>${plugin.name} - <small>${plugin.meta.human_name}</small></option>`; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         plugin_selection += ` |         plugin_selection += ` | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user