From 7f643f9c58c0c2f4e3216cc22f5922e953112c2e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 29 Aug 2023 15:07:08 -0400 Subject: [PATCH] Merge conditionals --- netbox/utilities/counters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/netbox/utilities/counters.py b/netbox/utilities/counters.py index 6b5adffad..6c1418dff 100644 --- a/netbox/utilities/counters.py +++ b/netbox/utilities/counters.py @@ -39,9 +39,8 @@ def post_save_receiver(sender, instance, created, **kwargs): # Update the counters on the old and/or new parents as needed if old_pk is not None: update_counter(parent_model, old_pk, counter_name, -1) - if new_pk is not None: - if old_pk or created: - update_counter(parent_model, new_pk, counter_name, 1) + if new_pk is not None and (old_pk or created): + update_counter(parent_model, new_pk, counter_name, 1) def post_delete_receiver(sender, instance, **kwargs):