Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5f47b22
Fix admin search for StockItemTracking and StockItemTestResult
bhumin18 Jul 31, 2026
bc960c2
Fix admin search for PartPricing, PartStocktake, PartRelated, and Par…
bhumin18 Jul 31, 2026
0955c90
Fix admin search for SalesOrderAllocation and ReturnOrderLineItem
bhumin18 Jul 31, 2026
2e0e69a
Fix incorrect identity comparison for status validation
bhumin18 Jul 31, 2026
60de032
Fix wrong super() method call in DataImportColumnMapAdmin
bhumin18 Jul 31, 2026
866a5d6
Fix broken delete() method signature on EmailMessage model
bhumin18 Jul 31, 2026
9ff90a3
Fix bare except clause in order status validation
bhumin18 Jul 31, 2026
eeff12e
Fix bare except clauses in machine registry and barcode mixins
bhumin18 Jul 31, 2026
fdc6719
Fix readonly_fields typos and add search_fields in admin classes
bhumin18 Aug 11, 2026
4405dcc
Merge branch 'master' into fix-admin-and-code-quality-improvements
SchrodingersGat Aug 11, 2026
ef9b1b9
Merge branch 'master' into fix-admin-and-code-quality-improvements
bhumin18 Aug 13, 2026
811d431
Merge branch 'master' into fix-admin-and-code-quality-improvements
bhumin18 Aug 14, 2026
4c4362c
Remove redundant admin field test assertions per review feedback
bhumin18 Aug 14, 2026
bd1e473
Merge branch 'master' into fix-admin-and-code-quality-improvements
bhumin18 Aug 17, 2026
49e9275
Merge branch 'master' into fix-admin-and-code-quality-improvements
bhumin18 Aug 20, 2026
1ca6fa2
Fix file formatting and end-of-file newlines per prek style check
bhumin18 Aug 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/backend/InvenTree/build/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class BuildItemAdmin(admin.ModelAdmin):

list_display = ('stock_item', 'quantity')

search_fields = [
'build_line__build__reference',
'build_line__build__title',
'stock_item__part__name',
'stock_item__serial',
]

autocomplete_fields = ['build_line', 'stock_item', 'install_into']


Expand Down
4 changes: 2 additions & 2 deletions src/backend/InvenTree/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3423,11 +3423,11 @@ def save(self, *args, **kwargs):

objects = NoDeleteManager()

def delete(self, *kwargs):
def delete(self, *args, **kwargs):
"""Delete entry - if not protected."""
if get_global_setting('INVENTREE_PROTECT_EMAIL_LOG'):
raise ValidationError(del_error_msg)
return super().delete(*kwargs)
return super().delete(*args, **kwargs)


class EmailThread(InvenTree.models.InvenTreeMetadataModel):
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/importer/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def formfield_for_dbfield(self, db_field, request, **kwargs):
session = queryset.first().session
db_field.choices = [(col, col) for col in session.columns]

return super().formfield_for_choice_field(db_field, request, **kwargs)
return super().formfield_for_dbfield(db_field, request, **kwargs)


@admin.register(importer.models.DataImportSession)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/machine/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MachineSettingInline(admin.TabularInline):

model = models.MachineSetting

read_only_fields = ['key', 'config_type']
readonly_fields = ['key', 'config_type']

def has_add_permission(self, request, obj):
"""The machine settings should not be meddled with manually."""
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/machine/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def _calculate_registry_hash(self):
data.update(str(pk).encode())
try:
data.update(str(machine.machine_config.active).encode())
except:
except Exception:
# machine does not exist anymore, hash will be different
pass

Expand Down
19 changes: 18 additions & 1 deletion src/backend/InvenTree/order/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ class SalesOrderAllocationAdmin(admin.ModelAdmin):

list_display = ('line', 'item', 'quantity')

search_fields = [
'line__order__reference',
'line__order__customer__name',
'line__part__name',
'item__part__name',
'item__part__IPN',
'item__serial',
]

autocomplete_fields = ('line', 'shipment', 'item')


Expand All @@ -171,11 +180,19 @@ class ReturnOrderLineItemAdmin(admin.ModelAdmin):

list_display = ['order', 'item', 'reference']

search_fields = [
'order__reference',
'order__customer__name',
'item__part__name',
'item__serial',
'reference',
]

autocomplete_fields = ['item', 'order']


@admin.register(models.ReturnOrderExtraLine)
class ReturnOrdeerExtraLineAdmin(GeneralExtraLineAdmin, admin.ModelAdmin):
class ReturnOrderExtraLineAdmin(GeneralExtraLineAdmin, admin.ModelAdmin):
"""Admin class for the ReturnOrderExtraLine model."""


Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/order/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def validate_status_custom_key(self, value):
custom_status = get_logical_value(
value, model=self.Meta.model._meta.model_name
)
except:
except Exception:
raise ValidationError(_('Invalid custom status key'))

if custom_status.logical_key is not self.instance.status:
Expand Down
10 changes: 0 additions & 10 deletions src/backend/InvenTree/order/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,3 @@ def test_updated_at_on_line_item_delete(self):
before = self._refresh(instance).updated_at
line.delete()
self.assertGreaterEqual(self._refresh(instance).updated_at, before)

def test_po_lineitem_admin_search(self):
"""Test search fields for PurchaseOrderLineItemAdmin."""
from order.admin import PurchaseOrderLineItemAdmin

admin_class = PurchaseOrderLineItemAdmin
self.assertIn('part__part__name', admin_class.search_fields)
self.assertIn('part__SKU', admin_class.search_fields)
self.assertIn('order__reference', admin_class.search_fields)
self.assertIn('order__supplier__name', admin_class.search_fields)
8 changes: 8 additions & 0 deletions src/backend/InvenTree/part/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PartPricingAdmin(admin.ModelAdmin):

list_display = ('part', 'overall_min', 'overall_max')

search_fields = ['part__name', 'part__IPN', 'part__description']

autocomplete_fields = ['part']


Expand All @@ -47,6 +49,8 @@ class PartStocktakeAdmin(admin.ModelAdmin):

list_display = ['part', 'date', 'quantity']

search_fields = ['part__name', 'part__IPN']


@admin.register(models.PartCategory)
class PartCategoryAdmin(admin.ModelAdmin):
Expand All @@ -63,6 +67,8 @@ class PartCategoryAdmin(admin.ModelAdmin):
class PartRelatedAdmin(admin.ModelAdmin):
"""Class to manage PartRelated objects."""

search_fields = ['part_1__name', 'part_2__name']

autocomplete_fields = ('part_1', 'part_2')


Expand All @@ -73,6 +79,8 @@ class PartTestTemplateAdmin(admin.ModelAdmin):
list_display = ('part', 'test_name', 'required')
readonly_fields = ['key']

search_fields = ['part__name', 'test_name', 'description']

autocomplete_fields = ('part',)


Expand Down
4 changes: 2 additions & 2 deletions src/backend/InvenTree/plugin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PluginSettingInline(admin.TabularInline):

model = models.PluginSetting

read_only_fields = ['key']
readonly_fields = ['key']

def has_add_permission(self, request, obj):
"""The plugin settings should not be meddled with manually."""
Expand All @@ -51,7 +51,7 @@ class PluginUserSettingInline(admin.TabularInline):

model = models.PluginUserSetting

read_only_fields = ['key']
readonly_fields = ['key']

def has_add_permission(self, request, obj):
"""The plugin user settings should not be meddled with manually."""
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/plugin/base/barcodes/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def has_barcode_generation(self):
except NotImplementedError:
# If a NotImplementedError is raised, then barcode generation is not supported
return False
except:
except Exception:
pass

return True
Expand Down
6 changes: 6 additions & 0 deletions src/backend/InvenTree/report/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ReportAdmin(admin.ModelAdmin):

list_filter = ('model_type', 'enabled')

search_fields = ['name', 'description']

def formfield_for_dbfield(self, db_field, request, **kwargs):
"""Provide custom choices for 'model_type' field."""
if db_field.name == 'model_type':
Expand All @@ -29,9 +31,13 @@ class ReportSnippetAdmin(admin.ModelAdmin):

list_display = ('id', 'snippet', 'description')

search_fields = ['description']


@admin.register(ReportAsset)
class ReportAssetAdmin(admin.ModelAdmin):
"""Admin class for the ReportAsset model."""

list_display = ('id', 'asset', 'description')

search_fields = ['description']
10 changes: 10 additions & 0 deletions src/backend/InvenTree/stock/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class StockTrackingAdmin(admin.ModelAdmin):

list_display = ('item', 'date', 'label')

search_fields = ['item__part__name', 'item__serial', 'notes']

autocomplete_fields = ['item']

def has_add_permission(self, request):
Expand All @@ -102,4 +104,12 @@ class StockItemTestResultAdmin(admin.ModelAdmin):

list_display = ('stock_item', 'test_name', 'result', 'value')

search_fields = [
'stock_item__part__name',
'stock_item__serial',
'template__test_name',
'value',
'notes',
]

autocomplete_fields = ['stock_item']
Loading