[PR #8176] [MERGED] Closes #7846: Associate inventory items with device components #13327

Closed
opened 2025-12-29 22:26:47 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/8176
Author: @jeremystretch
Created: 12/28/2021
Status: Merged
Merged: 12/28/2021
Merged by: @jeremystretch

Base: featureHead: 7846-inventoryitem-component


📝 Commits (8)

📊 Changes

31 files changed (+545 additions, -902 deletions)

View changed files

📝 docs/release-notes/version-3.2.md (+3 -1)
📝 netbox/dcim/api/serializers.py (+17 -2)
📝 netbox/dcim/constants.py (+18 -3)
📝 netbox/dcim/filtersets.py (+2 -0)
📝 netbox/dcim/forms/bulk_create.py (+2 -2)
📝 netbox/dcim/forms/models.py (+82 -68)
📝 netbox/dcim/forms/object_create.py (+67 -544)
netbox/dcim/migrations/0147_inventoryitem_component.py (+23 -0)
📝 netbox/dcim/models/device_components.py (+22 -0)
📝 netbox/dcim/tables/devices.py (+10 -5)
📝 netbox/dcim/tests/test_api.py (+16 -3)
📝 netbox/dcim/tests/test_filtersets.py (+13 -3)
📝 netbox/dcim/tests/test_forms.py (+8 -22)
📝 netbox/dcim/views.py (+44 -44)
📝 netbox/netbox/views/generic/object_views.py (+27 -11)
netbox/templates/dcim/component_create.html (+7 -0)
📝 netbox/templates/dcim/consoleport.html (+80 -79)
📝 netbox/templates/dcim/consoleserverport.html (+1 -0)
📝 netbox/templates/dcim/frontport.html (+1 -0)
netbox/templates/dcim/inc/panels/inventory_items.html (+59 -0)

...and 11 more files

📄 Description

Closes: #7846

  • Refactor ComponentCreateView to use separate forms for the component model and its replication
  • Remove most of the component-specific forms in dcim/object_create.py (removed a lot of redundancy with the model forms)
  • Convert static selection fields within component model forms to dynamic choice fields
  • Add a component GenericForeignKey on the InventoryItem model & updated tests
  • Added inventory item panels to the relevant device component views

We still need to come up with a better representation of the assigned component (if any) within the inventory item creation form. I'm hoping that we'll be able to leverage the solution for #8175 here.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/8176 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 12/28/2021 **Status:** ✅ Merged **Merged:** 12/28/2021 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `7846-inventoryitem-component` --- ### 📝 Commits (8) - [`99d5013`](https://github.com/netbox-community/netbox/commit/99d5013de30330a2c943ddb0e3030db0e49f6258) Initial work on #7846 - [`a237c01`](https://github.com/netbox-community/netbox/commit/a237c01b4b7e75664c180155e8e6689f163c55d3) Refactor ComponentCreateView to use separate forms for names/labels and model creation - [`ba85101`](https://github.com/netbox-community/netbox/commit/ba85101d30cde82a5e108f3c47ff2b7a28913694) Update component model forms to use DynamicModelChoiceField query_params for related objects - [`8ca09ec`](https://github.com/netbox-community/netbox/commit/8ca09ec07fdffc3caabd16866818503d93ad3225) Clean up form display - [`4075cc8`](https://github.com/netbox-community/netbox/commit/4075cc8518da585f35536f667c76c5293a520bdc) Restore front port component creation - [`e0319cc`](https://github.com/netbox-community/netbox/commit/e0319cc894f3218afe6d727eea08485634c7f188) Clean up form rendering - [`a0836b6`](https://github.com/netbox-community/netbox/commit/a0836b6876f94ef596f02277323bf2c9017968a8) Add inventory items panel to device component views - [`4c5a5c7`](https://github.com/netbox-community/netbox/commit/4c5a5c70b0129febfe191c70cce300aecba1aa8c) Changelog for #7846 ### 📊 Changes **31 files changed** (+545 additions, -902 deletions) <details> <summary>View changed files</summary> 📝 `docs/release-notes/version-3.2.md` (+3 -1) 📝 `netbox/dcim/api/serializers.py` (+17 -2) 📝 `netbox/dcim/constants.py` (+18 -3) 📝 `netbox/dcim/filtersets.py` (+2 -0) 📝 `netbox/dcim/forms/bulk_create.py` (+2 -2) 📝 `netbox/dcim/forms/models.py` (+82 -68) 📝 `netbox/dcim/forms/object_create.py` (+67 -544) ➕ `netbox/dcim/migrations/0147_inventoryitem_component.py` (+23 -0) 📝 `netbox/dcim/models/device_components.py` (+22 -0) 📝 `netbox/dcim/tables/devices.py` (+10 -5) 📝 `netbox/dcim/tests/test_api.py` (+16 -3) 📝 `netbox/dcim/tests/test_filtersets.py` (+13 -3) 📝 `netbox/dcim/tests/test_forms.py` (+8 -22) 📝 `netbox/dcim/views.py` (+44 -44) 📝 `netbox/netbox/views/generic/object_views.py` (+27 -11) ➕ `netbox/templates/dcim/component_create.html` (+7 -0) 📝 `netbox/templates/dcim/consoleport.html` (+80 -79) 📝 `netbox/templates/dcim/consoleserverport.html` (+1 -0) 📝 `netbox/templates/dcim/frontport.html` (+1 -0) ➕ `netbox/templates/dcim/inc/panels/inventory_items.html` (+59 -0) _...and 11 more files_ </details> ### 📄 Description ### Closes: #7846 - Refactor ComponentCreateView to use separate forms for the component model and its replication - Remove most of the component-specific forms in `dcim/object_create.py` (removed a lot of redundancy with the model forms) - Convert static selection fields within component model forms to dynamic choice fields - Add a `component` GenericForeignKey on the InventoryItem model & updated tests - Added inventory item panels to the relevant device component views We still need to come up with a better representation of the assigned component (if any) within the inventory item creation form. I'm hoping that we'll be able to leverage the solution for #8175 here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:26:47 +01:00
adam closed this issue 2025-12-29 22:26:47 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13327