diff --git a/src/backend/InvenTree/InvenTree/tracing.py b/src/backend/InvenTree/InvenTree/tracing.py index 3d3eda28a3..dd90a330dd 100644 --- a/src/backend/InvenTree/InvenTree/tracing.py +++ b/src/backend/InvenTree/InvenTree/tracing.py @@ -22,9 +22,6 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExport import InvenTree.ready from InvenTree.version import inventreeVersion -# Logger configuration -logger = logging.getLogger('inventree') - def setup_tracing( endpoint: str, @@ -46,6 +43,9 @@ def setup_tracing( if InvenTree.ready.isImportingData() or InvenTree.ready.isRunningMigrations(): return + # Logger configuration + logger = logging.getLogger('inventree') + if resources_input is None: resources_input = {} if auth is None: diff --git a/src/backend/InvenTree/InvenTree/unit_test.py b/src/backend/InvenTree/InvenTree/unit_test.py index 94af1325c4..3f64fe1d9c 100644 --- a/src/backend/InvenTree/InvenTree/unit_test.py +++ b/src/backend/InvenTree/InvenTree/unit_test.py @@ -84,6 +84,9 @@ def getNewestMigrationFile(app, exclude_extension=True): newest_num = num newest_file = f + if not newest_file: # pragma: no cover + return newest_file + if exclude_extension: newest_file = newest_file.replace('.py', '') diff --git a/src/backend/InvenTree/common/forms.py b/src/backend/InvenTree/common/forms.py index b991eec06b..4800149013 100644 --- a/src/backend/InvenTree/common/forms.py +++ b/src/backend/InvenTree/common/forms.py @@ -51,6 +51,9 @@ class MatchFieldForm(forms.Form): super().__init__(*args, **kwargs) + if not file_manager: # pragma: no cover + return + # Setup FileManager file_manager.setup() # Get columns @@ -87,6 +90,9 @@ class MatchItemForm(forms.Form): super().__init__(*args, **kwargs) + if not file_manager: # pragma: no cover + return + # Setup FileManager file_manager.setup() diff --git a/src/backend/InvenTree/stock/models.py b/src/backend/InvenTree/stock/models.py index 6008f8cf59..3a65f2c2f6 100644 --- a/src/backend/InvenTree/stock/models.py +++ b/src/backend/InvenTree/stock/models.py @@ -714,8 +714,6 @@ class StockItem( self.delete_on_deplete = False except PartModels.Part.DoesNotExist: - # This gets thrown if self.supplier_part is null - # TODO - Find a test than can be performed... pass # Ensure that the item cannot be assigned to itself @@ -1109,7 +1107,11 @@ class StockItem( item.add_tracking_entry(code, user, deltas, notes=notes) - trigger_event('stockitem.assignedtocustomer', id=self.id, customer=customer.id) + trigger_event( + 'stockitem.assignedtocustomer', + id=self.id, + customer=customer.id if customer else None, + ) # Return the reference to the stock item return item @@ -1773,7 +1775,7 @@ class StockItem( price = convert_money(price, base_currency) total_price += price * qty quantity += qty - except: + except Exception: # Skip this entry, cannot convert to base currency continue diff --git a/src/backend/InvenTree/templates/js/dynamic/nav.js b/src/backend/InvenTree/templates/js/dynamic/nav.js index f207bf110d..188e7be98b 100644 --- a/src/backend/InvenTree/templates/js/dynamic/nav.js +++ b/src/backend/InvenTree/templates/js/dynamic/nav.js @@ -1,4 +1,5 @@ /* globals + inventreeGet, */ /* exported @@ -25,8 +26,8 @@ function activatePanel(label, panel_name, options={}) { panel_name = panel_name.replace('/', ''); // Find the target panel - var panel = `#panel-${panel_name}`; - var select = `#select-${panel_name}`; + let panel = `#panel-${panel_name}`; + let select = `#select-${panel_name}`; // Check that the selected panel (and select) exist if ($(panel).exists() && $(panel).length && $(select).length) { @@ -37,7 +38,7 @@ function activatePanel(label, panel_name, options={}) { panel_name = null; $('.sidebar-selector').each(function() { - var name = $(this).attr('id').replace('select-', ''); + const name = $(this).attr('id').replace('select-', ''); if ($(`#panel-${name}`).length && (panel_name == null)) { panel_name = name; @@ -64,7 +65,7 @@ function activatePanel(label, panel_name, options={}) { $('.list-group-item').removeClass('active'); // Find the associated selector - var selector = `#select-${panel_name}`; + const selector = `#select-${panel_name}`; $(selector).addClass('active'); } @@ -75,7 +76,7 @@ function onPanelLoad(panel, callback) { // Used to implement lazy-loading, rather than firing // multiple AJAX queries when the page is first loaded. - var panelId = `#panel-${panel}`; + const panelId = `#panel-${panel}`; $(panelId).on('fadeInStarted', function() { @@ -96,10 +97,10 @@ function enableSidebar(label, options={}) { // Enable callbacks for sidebar buttons $('.sidebar-selector').click(function() { - var el = $(this); + const el = $(this); // Find the matching panel element to display - var panel_name = el.attr('id').replace('select-', ''); + const panel_name = el.attr('id').replace('select-', ''); activatePanel(label, panel_name, options); }); @@ -111,16 +112,16 @@ function enableSidebar(label, options={}) { * - Third preference = default */ - var selected_panel = $.urlParam('display') || localStorage.getItem(`inventree-selected-panel-${label}`) || options.default; + const selected_panel = $.urlParam('display') || localStorage.getItem(`inventree-selected-panel-${label}`) || options.default; if (selected_panel) { activatePanel(label, selected_panel); } else { // Find the "first" available panel (according to the sidebar) - var selector = $('.sidebar-selector').first(); + const selector = $('.sidebar-selector').first(); if (selector.exists()) { - var panel_name = selector.attr('id').replace('select-', ''); + const panel_name = selector.attr('id').replace('select-', ''); activatePanel(label, panel_name); } } @@ -133,7 +134,7 @@ function enableSidebar(label, options={}) { // Add callback to "collapse" and "expand" the sidebar // By default, the menu is "expanded" - var state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded'; + const state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded'; // We wish to "toggle" the state! setSidebarState(label, state == 'expanded' ? 'collapsed' : 'expanded'); @@ -141,7 +142,7 @@ function enableSidebar(label, options={}) { } // Set the initial state (default = expanded) - var state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded'; + const state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded'; setSidebarState(label, state); @@ -161,10 +162,8 @@ function enableSidebar(label, options={}) { function generateTreeStructure(data, options) { const nodes = {}; const roots = []; - let node = null; - for (var i = 0; i < data.length; i++) { - node = data[i]; + for (let node of data) { nodes[node.pk] = node; node.selectable = false; @@ -178,9 +177,7 @@ function generateTreeStructure(data, options) { } } - for (var i = 0; i < data.length; i++) { - node = data[i]; - + for (let node of data) { if (node.parent != null) { if (nodes[node.parent].nodes) { nodes[node.parent].nodes.push(node); @@ -208,14 +205,14 @@ function generateTreeStructure(data, options) { */ function enableBreadcrumbTree(options) { - var label = options.label; + const label = options.label; if (!label) { console.error('enableBreadcrumbTree called without supplying label'); return; } - var filters = options.filters || {}; + const filters = options.filters || {}; inventreeGet( options.url, @@ -283,7 +280,7 @@ function setSidebarState(label, state) { */ function addSidebarItem(options={}) { - var html = ` + const html = ` ${options.content_before || ''} @@ -302,7 +299,7 @@ function addSidebarItem(options={}) { */ function addSidebarHeader(options={}) { - var html = ` + const html = `
diff --git a/src/backend/InvenTree/templates/js/dynamic/permissions.js b/src/backend/InvenTree/templates/js/dynamic/permissions.js index 34881a8dcf..309ebe529b 100644 --- a/src/backend/InvenTree/templates/js/dynamic/permissions.js +++ b/src/backend/InvenTree/templates/js/dynamic/permissions.js @@ -7,7 +7,7 @@ */ // Keep track of the current user permissions -var user_roles = null; +let user_roles = null; /* diff --git a/src/frontend/src/components/buttons/CopyButton.tsx b/src/frontend/src/components/buttons/CopyButton.tsx index bf51eebd0b..3ac02e5da2 100644 --- a/src/frontend/src/components/buttons/CopyButton.tsx +++ b/src/frontend/src/components/buttons/CopyButton.tsx @@ -20,8 +20,12 @@ export function CopyButton({ size="compact-md" > - {label &&
 
} - {label && label} + {label && ( + <> +
 
+ {label} + + )} )} diff --git a/src/frontend/src/tables/settings/GroupTable.tsx b/src/frontend/src/tables/settings/GroupTable.tsx index 7ffa794415..bbbd05a3c3 100644 --- a/src/frontend/src/tables/settings/GroupTable.tsx +++ b/src/frontend/src/tables/settings/GroupTable.tsx @@ -112,7 +112,8 @@ export function GroupTable() { }), RowDeleteAction({ onClick: () => { - setSelectedGroup(record.pk), deleteGroup.open(); + setSelectedGroup(record.pk); + deleteGroup.open(); } }) ];