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

Conversation

lukaszkarykowski
Copy link
Contributor

Search fields, search changed to find exact barcode

@@ -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

@awieckowski awieckowski merged commit d0b1e04 into allegro:ng Mar 4, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants