Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITS-363398 | Search fields, search changed to find exact barcode #3716

Merged
Merged
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion src/ralph/back_office/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
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',
Expand Down
Loading