fix: global tenant filter includes assets with inherited tenant
The tenant_id and tenant_group_id filters of netbox-inventory assets now also match assets without their own tenant via the tenant of the assigned device, module, inventory item or rack, like the tenant column. The global tenant and tenant group filter uses these filters and no longer hides such assets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
204bb235a4
commit
bfcfff60e4
4 files changed
+57
-2
No files matched your search
@@ -38,3 +38,14 @@ class AssetTenantFallbackTest(SimpleTestCase):
|
||||
module = SimpleNamespace(device=SimpleNamespace(tenant="C"))
|
||||
self.assertEqual(asset_tenant(asset(module=module)), "C")
|
||||
self.assertIsNone(asset_tenant(asset()))
|
||||
|
||||
|
||||
class AssetTenantQueryTest(SimpleTestCase):
|
||||
def test_query_includes_inherited_tenants_only_without_own_tenant(self):
|
||||
from netbox_utilities.inventory_assets import asset_tenant_query
|
||||
|
||||
query = str(asset_tenant_query([7]))
|
||||
|
||||
for lookup in ("tenant_id__in", "tenant__isnull", "device__tenant_id__in", "module__device__tenant_id__in",
|
||||
"inventoryitem__device__tenant_id__in", "rack__tenant_id__in"):
|
||||
self.assertIn(f"'{lookup}'", query)
|
||||
Reference in new issue
Block a user