Coverage for src/backend/InvenTree/common/setting/user.py: 92%
11 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""User settings definition."""
3from django.core.validators import MinValueValidator
4from django.utils.translation import gettext_lazy as _
6from common.setting.type import InvenTreeSettingsKeyType
7from plugin import PluginMixinEnum, registry
10def label_printer_options():
11 """Build a list of available label printer options."""
12 printers = []
13 label_printer_plugins = registry.with_mixin(PluginMixinEnum.LABELS)
14 if label_printer_plugins: 14 ↛ 18line 14 didn't jump to line 18 because the condition on line 14 was always true
15 printers.extend([
16 (p.slug, p.name + ' - ' + p.human_name) for p in label_printer_plugins
17 ])
18 return printers
21USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
22 'LABEL_INLINE': {
23 'name': _('Inline label display'),
24 'description': _(
25 'Display PDF labels in the browser, instead of downloading as a file'
26 ),
27 'default': True,
28 'validator': bool,
29 },
30 'LABEL_DEFAULT_PRINTER': {
31 'name': _('Default label printer'),
32 'description': _('Configure which label printer should be selected by default'),
33 'default': '',
34 'choices': label_printer_options,
35 },
36 'REPORT_INLINE': {
37 'name': _('Inline report display'),
38 'description': _(
39 'Display PDF reports in the browser, instead of downloading as a file'
40 ),
41 'default': False,
42 'validator': bool,
43 },
44 'BARCODE_IN_FORM_FIELDS': {
45 'name': _('Barcode Scanner in Form Fields'),
46 'description': _('Allow barcode scanner input in form fields'),
47 'default': False,
48 'validator': bool,
49 },
50 'SEARCH_PREVIEW_SHOW_PARTS': {
51 'name': _('Search Parts'),
52 'description': _('Display parts in search preview window'),
53 'default': True,
54 'validator': bool,
55 },
56 'SEARCH_PREVIEW_SHOW_SUPPLIER_PARTS': {
57 'name': _('Search Supplier Parts'),
58 'description': _('Display supplier parts in search preview window'),
59 'default': True,
60 'validator': bool,
61 },
62 'SEARCH_PREVIEW_SHOW_MANUFACTURER_PARTS': {
63 'name': _('Search Manufacturer Parts'),
64 'description': _('Display manufacturer parts in search preview window'),
65 'default': True,
66 'validator': bool,
67 },
68 'SEARCH_HIDE_INACTIVE_PARTS': {
69 'name': _('Hide Inactive Parts'),
70 'description': _('Excluded inactive parts from search preview window'),
71 'default': False,
72 'validator': bool,
73 },
74 'SEARCH_PREVIEW_SHOW_CATEGORIES': {
75 'name': _('Search Categories'),
76 'description': _('Display part categories in search preview window'),
77 'default': False,
78 'validator': bool,
79 },
80 'SEARCH_PREVIEW_SHOW_STOCK': {
81 'name': _('Search Stock'),
82 'description': _('Display stock items in search preview window'),
83 'default': True,
84 'validator': bool,
85 },
86 'SEARCH_PREVIEW_HIDE_UNAVAILABLE_STOCK': {
87 'name': _('Hide Unavailable Stock Items'),
88 'description': _(
89 'Exclude stock items which are not available from the search preview window'
90 ),
91 'validator': bool,
92 'default': False,
93 },
94 'SEARCH_PREVIEW_SHOW_LOCATIONS': {
95 'name': _('Search Locations'),
96 'description': _('Display stock locations in search preview window'),
97 'default': False,
98 'validator': bool,
99 },
100 'SEARCH_PREVIEW_SHOW_COMPANIES': {
101 'name': _('Search Companies'),
102 'description': _('Display companies in search preview window'),
103 'default': True,
104 'validator': bool,
105 },
106 'SEARCH_PREVIEW_SHOW_BUILD_ORDERS': {
107 'name': _('Search Build Orders'),
108 'description': _('Display build orders in search preview window'),
109 'default': True,
110 'validator': bool,
111 },
112 'SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS': {
113 'name': _('Search Purchase Orders'),
114 'description': _('Display purchase orders in search preview window'),
115 'default': True,
116 'validator': bool,
117 },
118 'SEARCH_PREVIEW_EXCLUDE_INACTIVE_PURCHASE_ORDERS': {
119 'name': _('Exclude Inactive Purchase Orders'),
120 'description': _('Exclude inactive purchase orders from search preview window'),
121 'default': True,
122 'validator': bool,
123 },
124 'SEARCH_PREVIEW_SHOW_SALES_ORDERS': {
125 'name': _('Search Sales Orders'),
126 'description': _('Display sales orders in search preview window'),
127 'default': True,
128 'validator': bool,
129 },
130 'SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS': {
131 'name': _('Exclude Inactive Sales Orders'),
132 'description': _('Exclude inactive sales orders from search preview window'),
133 'validator': bool,
134 'default': True,
135 },
136 'SEARCH_PREVIEW_SHOW_SALES_ORDER_SHIPMENTS': {
137 'name': _('Search Sales Order Shipments'),
138 'description': _('Display sales order shipments in search preview window'),
139 'default': True,
140 'validator': bool,
141 },
142 'SEARCH_PREVIEW_SHOW_RETURN_ORDERS': {
143 'name': _('Search Return Orders'),
144 'description': _('Display return orders in search preview window'),
145 'default': True,
146 'validator': bool,
147 },
148 'SEARCH_PREVIEW_EXCLUDE_INACTIVE_RETURN_ORDERS': {
149 'name': _('Exclude Inactive Return Orders'),
150 'description': _('Exclude inactive return orders from search preview window'),
151 'validator': bool,
152 'default': True,
153 },
154 'SEARCH_PREVIEW_RESULTS': {
155 'name': _('Search Preview Results'),
156 'description': _(
157 'Number of results to show in each section of the search preview window'
158 ),
159 'default': 10,
160 'validator': [int, MinValueValidator(1)],
161 },
162 'SEARCH_REGEX': {
163 'name': _('Regex Search'),
164 'description': _('Enable regular expressions in search queries'),
165 'default': False,
166 'validator': bool,
167 },
168 'SEARCH_WHOLE': {
169 'name': _('Whole Word Search'),
170 'description': _('Search queries return results for whole word matches'),
171 'default': False,
172 'validator': bool,
173 },
174 'SEARCH_NOTES': {
175 'name': _('Search Notes'),
176 'description': _(
177 "Search queries return results for matches from the item's notes"
178 ),
179 'default': False,
180 'validator': bool,
181 },
182 'FORMS_CLOSE_USING_ESCAPE': {
183 'name': _('Escape Key Closes Forms'),
184 'description': _('Use the escape key to close modal forms'),
185 'default': False,
186 'validator': bool,
187 },
188 'STICKY_HEADER': {
189 'name': _('Fixed Navbar'),
190 'description': _('The navbar position is fixed to the top of the screen'),
191 'default': False,
192 'validator': bool,
193 },
194 'STICKY_TABLE_HEADER': {
195 'name': _('Fixed Table Headers'),
196 'description': _('Table headers are fixed to the top of the table'),
197 'default': False,
198 'validator': bool,
199 },
200 'SHOW_SPOTLIGHT': {
201 'name': _('Show Spotlight'),
202 'description': _('Enable spotlight navigation functionality'),
203 'default': True,
204 'validator': bool,
205 },
206 'ICONS_IN_NAVBAR': {
207 'name': _('Navigation Icons'),
208 'description': _('Display icons in the navigation bar'),
209 'default': False,
210 'validator': bool,
211 },
212 'DATE_DISPLAY_FORMAT': {
213 'name': _('Date Format'),
214 'description': _('Preferred format for displaying dates'),
215 'default': 'YYYY-MM-DD',
216 'choices': [
217 ('YYYY-MM-DD', '2022-02-22'),
218 ('YYYY/MM/DD', '2022/22/22'),
219 ('DD-MM-YYYY', '22-02-2022'),
220 ('DD/MM/YYYY', '22/02/2022'),
221 ('MM-DD-YYYY', '02-22-2022'),
222 ('MM/DD/YYYY', '02/22/2022'),
223 ('MMM DD YYYY', 'Feb 22 2022'),
224 ],
225 },
226 'DISPLAY_STOCKTAKE_TAB': {
227 'name': _('Show Stock History'),
228 'description': _('Display stock history information in the part detail page'),
229 'default': True,
230 'validator': bool,
231 },
232 'ENABLE_LAST_BREADCRUMB': {
233 'name': _('Show Last Breadcrumb'),
234 'description': _('Show the current page in breadcrumbs'),
235 'default': False,
236 'validator': bool,
237 },
238 'SHOW_EXTRA_MODEL_INFO': {
239 'name': _('Show Extra Model Information'),
240 'description': _('Display extra information in model selection dropdowns'),
241 'default': False,
242 'validator': bool,
243 },
244 'SHOW_FULL_LOCATION_IN_TABLES': {
245 'name': _('Show full stock location in tables'),
246 'description': _(
247 'Disabled: The full location path is displayed as a hover tooltip. Enabled: The full location path is displayed as plain text.'
248 ),
249 'default': False,
250 'validator': bool,
251 },
252 'SHOW_FULL_CATEGORY_IN_TABLES': {
253 'name': _('Show full part categories in tables'),
254 'description': _(
255 'Disabled: The full category path is displayed as a hover tooltip. Enabled: The full category path is displayed as plain text.'
256 ),
257 'default': False,
258 'validator': bool,
259 },
260 'SHOW_BOM_SUBASSEMBLY_LEVELS': {
261 'name': _('Show Subassemblies in BOM table'),
262 'description': _('Enable display of subassemblies in the BOM table'),
263 'default': True,
264 'validator': bool,
265 },
266 'NOTIFICATION_ERROR_REPORT': {
267 'name': _('Receive error reports'),
268 'description': _('Receive notifications for system errors'),
269 'default': True,
270 'validator': bool,
271 },
272 'LAST_USED_PRINTING_MACHINES': {
273 'name': _('Last used printing machines'),
274 'description': _('Save the last used printing machines for a user'),
275 'default': '',
276 },
277 'DISPLAY_ITEMS_FINAL_LEVEL': {
278 'name': _('Display Items at Final Level'),
279 'description': _(
280 'Automatically default to showing items/parts instead of sub-levels for locations or categories with no children'
281 ),
282 'default': False,
283 'validator': bool,
284 },
285}