From 8fc41f9aaf82f06029d7e43f69652f5d82a5b823 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 16 Oct 2023 10:41:28 -0700 Subject: [PATCH] 14042 fix cache count for mptt child delete --- netbox/utilities/counters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netbox/utilities/counters.py b/netbox/utilities/counters.py index 6c597b943..89e068aec 100644 --- a/netbox/utilities/counters.py +++ b/netbox/utilities/counters.py @@ -72,7 +72,10 @@ def post_delete_receiver(sender, instance, **kwargs): # Decrement the parent's counter by one if parent_pk is not None: - update_counter(parent_model, parent_pk, counter_name, -1) + # MPTT sends two delete signals if child element so guard against multiple decrements + origin = kwargs.get('origin') + if not origin or origin == instance: + update_counter(parent_model, parent_pk, counter_name, -1) #