1
0
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:
jeremystretch
2021-12-27 13:26:17 -05:00
parent a58f1c6a7d
commit 99d5013de3
11 changed files with 161 additions and 22 deletions

View File

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