From 089530ffb6cd8778bf4e0d03bc952d2beabd8999 Mon Sep 17 00:00:00 2001 From: "lukasz.karykowski" Date: Fri, 4 Mar 2022 08:04:35 +0100 Subject: [PATCH 1/2] ITS-363398 | Search fields search changed to find exact barcode --- src/ralph/back_office/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ralph/back_office/admin.py b/src/ralph/back_office/admin.py index 560063d09e..28f44a6438 100644 --- a/src/ralph/back_office/admin.py +++ b/src/ralph/back_office/admin.py @@ -117,7 +117,7 @@ class BackOfficeAssetAdmin( ] multiadd_summary_fields = list_display - search_fields = ['barcode', 'sn', 'hostname', 'invoice_no', 'order_no'] + search_fields = ['=barcode', 'sn', 'hostname', 'invoice_no', 'order_no'] list_filter = [ 'barcode', 'status', 'imei', 'imei2', 'sn', 'model', 'purchase_order', From ac17fb69f11ac32a6e9f4e73ae581a1b88df18eb Mon Sep 17 00:00:00 2001 From: "lukasz.karykowski" Date: Fri, 1 Mar 2024 15:00:55 +0100 Subject: [PATCH 2/2] 3716 | Changed code suggested in comment. --- src/ralph/back_office/admin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ralph/back_office/admin.py b/src/ralph/back_office/admin.py index 28f44a6438..d0d4fb92ae 100644 --- a/src/ralph/back_office/admin.py +++ b/src/ralph/back_office/admin.py @@ -117,7 +117,14 @@ class BackOfficeAssetAdmin( ] multiadd_summary_fields = list_display - search_fields = ['=barcode', 'sn', 'hostname', 'invoice_no', 'order_no'] + search_fields = ['barcode', 'sn', 'hostname', 'invoice_no', 'order_no'] + + def get_search_results(self, request, queryset, search_term): + queryset, use_distinct = super().get_search_results(request, queryset, search_term) # noqa + if 'barcode' in request.GET: + barcode = request.GET.get('barcode') + queryset = self.model.objects.filter(barcode__exact=barcode) + return queryset, use_distinct list_filter = [ 'barcode', 'status', 'imei', 'imei2', 'sn', 'model', 'purchase_order',