Netbox 2.10.1 When searching for a serial, open the view for that item and show the serial in the returned list #4381

Closed
opened 2025-12-29 18:35:27 +01:00 by adam · 4 comments
Owner

Originally created by @lastwednesday on GitHub (Dec 19, 2020).

Environment

  • Python version: 3.8.3
  • NetBox version: 2.10.1

Proposed Functionality

What would be a little more user friendly, is if a user performs a search for a serial, if that serial is found as an inventory item, then return the link to open the inventory item, vs showing the link for the parent device.

In addition when searching for a serial, it would be helpful if the results returned included the serials in the list.

Use Case

We have a large number of devices in our environment which contain up to 8 or so expansion enclosures marked as inventory items of the control enclosure. When searching for a serial number, if the serial number is for an Inventory item, the search will just bring up the link for the device which contains the inventory item.

For example starting with this setup:

  1. A device containing multiple inventory items:
    image
    image
  2. Search either at the top search bar or device search bar for a serial of one of the inventory items:
    image
  3. Note that the returned response will show the link to the device containing the inventory item and then the user must click on that and drill down over to the Inventory items tab, then click on the inventory item to open up what was searched for, instead of the search bringing up the direct link to the inventory item:
    image

While looking into this flow, I also noticed a gap where if one searches for a serial then the list returned doesn't actually display the serial in the returned item. For example if one were to query a serial number by a known vendor prefix then the list would show the devices which matches but not the serials for them.

  1. A list of devices with a common serial prefix:
    image
  2. Search for the serial prefix XXYY from the top search bar or from the search bar on the main page:
    image
  3. The returned list does not have choosable columns, and one of the ones that is missing is the serial number:
    image

Database Changes

Should not require adding new models

External Dependencies

No new external dependencies

Originally created by @lastwednesday on GitHub (Dec 19, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.8.3 * NetBox version: 2.10.1 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality What would be a little more user friendly, is if a user performs a search for a serial, if that serial is found as an inventory item, then return the link to open the inventory item, vs showing the link for the parent device. In addition when searching for a serial, it would be helpful if the results returned included the serials in the list. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case We have a large number of devices in our environment which contain up to 8 or so expansion enclosures marked as inventory items of the control enclosure. When searching for a serial number, if the serial number is for an Inventory item, the search will just bring up the link for the device which contains the inventory item. For example starting with this setup: 1. A device containing multiple inventory items: ![image](https://user-images.githubusercontent.com/579420/102673268-1418da80-4159-11eb-8fcd-a7afd5eeb5b6.png) ![image](https://user-images.githubusercontent.com/579420/102673328-4fb3a480-4159-11eb-8dc6-862a5866dded.png) 2. Search either at the top search bar or device search bar for a serial of one of the inventory items: ![image](https://user-images.githubusercontent.com/579420/102673367-783b9e80-4159-11eb-9389-d599868e706c.png) 3. Note that the returned response will show the link to the device containing the inventory item and then the user must click on that and drill down over to the Inventory items tab, then click on the inventory item to open up what was searched for, instead of the search bringing up the direct link to the inventory item: ![image](https://user-images.githubusercontent.com/579420/102673412-aa4d0080-4159-11eb-86b1-cd19a0fd5a0d.png) While looking into this flow, I also noticed a gap where if one searches for a serial then the list returned doesn't actually display the serial in the returned item. For example if one were to query a serial number by a known vendor prefix then the list would show the devices which matches but not the serials for them. 1. A list of devices with a common serial prefix: ![image](https://user-images.githubusercontent.com/579420/102674070-437c1700-415a-11eb-8822-b42ed8742ee9.png) 2. Search for the serial prefix XXYY from the top search bar or from the search bar on the main page: ![image](https://user-images.githubusercontent.com/579420/102674200-c56c4000-415a-11eb-88c2-50c2835dbc3d.png) 3. The returned list does not have choosable columns, and one of the ones that is missing is the serial number: ![image](https://user-images.githubusercontent.com/579420/102674240-fb112900-415a-11eb-83ec-85e122e7f059.png) <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes Should not require adding new models <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies No new external dependencies
adam added the type: featurestatus: under review labels 2025-12-29 18:35:27 +01:00
adam closed this issue 2025-12-29 18:35:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2020):

I'm afraid the current search implementation doesn't allow for this. When searching devices, we are querying the devices database table and pulling in certain related objects (e.g. inventory items) for filtering. This query must return only device objects due to how the ORM works. (The global search works much the same way, but queries additional object types in addition to device.) Changing this would require overhauling the entire search mechanism.

As a workaround, if you know that you're looking for an inventory item, you can search for a serial number using the inventory item list view.

@jeremystretch commented on GitHub (Dec 21, 2020): I'm afraid the current search implementation doesn't allow for this. When searching devices, we are querying the devices database table and pulling in certain related objects (e.g. inventory items) for filtering. This query _must_ return only device objects due to how the ORM works. (The global search works much the same way, but queries additional object types in addition to device.) Changing this would require overhauling the entire search mechanism. As a workaround, if you know that you're looking for an inventory item, you can search for a serial number using the inventory item list view.
Author
Owner

@lastwednesday commented on GitHub (Dec 21, 2020):

Got it. When we are searching we don't necessarily know at the beginning if the serial is for an inventory item (eg an expansion enclosure) or for a device object (eg a control enclosure). So it'd be a few extra steps to find the details if it turns out to be in the inventory. If we're looking for a complete inventory of all our enclosures we need to look at the Devices table and then also look in the Inventory items table. So I was hoping if we did a search it'd simplify finding things promptly. An alternative might be to have a third table which shows a complete list of all devices including all their inventory items below each.

What about getting serials to display in the results table, or allowing the user to choose which columns to view in results as we can for most other tables?

@lastwednesday commented on GitHub (Dec 21, 2020): Got it. When we are searching we don't necessarily know at the beginning if the serial is for an inventory item (eg an expansion enclosure) or for a device object (eg a control enclosure). So it'd be a few extra steps to find the details if it turns out to be in the inventory. If we're looking for a complete inventory of all our enclosures we need to look at the Devices table and then also look in the Inventory items table. So I was hoping if we did a search it'd simplify finding things promptly. An alternative might be to have a third table which shows a complete list of all devices including all their inventory items below each. What about getting serials to display in the results table, or allowing the user to choose which columns to view in results as we can for most other tables?
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2020):

That's not going to be feasible either given the current implementation. A new search solution would be needed, which unfortunately isn't something I can commit effort to at this time.

@jeremystretch commented on GitHub (Dec 21, 2020): That's not going to be feasible either given the current implementation. A new search solution would be needed, which unfortunately isn't something I can commit effort to at this time.
Author
Owner

@lastwednesday commented on GitHub (Dec 21, 2020):

Ok, thanks for the consideration. I'll close this one out.

@lastwednesday commented on GitHub (Dec 21, 2020): Ok, thanks for the consideration. I'll close this one out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4381