Fixes #17954 - Add dynamic parent resolution for cable CSV imports #20843
+385
−46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #17954
Overview
This PR implements dynamic parent resolution for cable CSV imports, enabling bulk import of cables connected to circuits, power panels, and devices. This is a revised approach following PR #17995, which was closed due to design concerns.
Key Difference from PR #17995:
Instead of adding separate fields for each parent type (
side_x_circuit,side_x_power_panel), this implementation uses dynamic parent resolution by repurposing the existingside_x_devicefield toside_x_parent. The parent object (Circuit, Device, or PowerPanel) is determined based on the termination type specified.Implementation Details
1. Dynamic Parent Field Resolution:
side_x_devicetoside_x_parentinCableImportFormside_x_termination_typedcim.device→ Resolves using Device modelcircuits.circuit→ Resolves using Circuit modeldcim.powerpanel→ Resolves using PowerPanel model2. Parent-Specific Lookup Logic:
cid(Circuit ID) as the lookup fieldnameas the lookup fieldnameas the lookup field3. Enhanced Validation:
4. Comprehensive Test Coverage:
Benefits
Usage Example