mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Initial work on #7846
This commit is contained in:
@@ -97,6 +97,12 @@ class ModularComponentModel(ComponentModel):
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
inventory_items = GenericRelation(
|
||||
to='dcim.InventoryItem',
|
||||
content_type_field='component_type',
|
||||
object_id_field='component_id',
|
||||
related_name='%(class)ss',
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
@@ -994,6 +1000,22 @@ class InventoryItem(MPTTModel, ComponentModel):
|
||||
null=True,
|
||||
db_index=True
|
||||
)
|
||||
component_type = models.ForeignKey(
|
||||
to=ContentType,
|
||||
limit_choices_to=MODULAR_COMPONENT_MODELS,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+',
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
component_id = models.PositiveBigIntegerField(
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
component = GenericForeignKey(
|
||||
ct_field='component_type',
|
||||
fk_field='component_id'
|
||||
)
|
||||
role = models.ForeignKey(
|
||||
to='dcim.InventoryItemRole',
|
||||
on_delete=models.PROTECT,
|
||||
|
Reference in New Issue
Block a user