From af236ef5c089350d03dbfe033d4128f81b6bc515 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sat, 22 Oct 2016 09:47:33 +0200 Subject: Improve cached label regeneration when modifying parent items (refs #3341) --- ishtar_common/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ishtar_common') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 60c3ac7ef..82d4f2caa 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -56,10 +56,17 @@ def cached_label_changed(sender, **kwargs): if not kwargs.get('instance'): return instance = kwargs.get('instance') + if hasattr(instance, '_cached_label_checked'): + return + instance._cached_label_checked = True lbl = instance._generate_cached_label() if lbl != instance.cached_label: + instance.skip_history_when_saving = True instance.cached_label = lbl instance.save() + if hasattr(instance, '_get_associated_cached_labels'): + for item in instance._get_associated_cached_labels(): + cached_label_changed(item.__class__, instance=item) SHORTIFY_STR = ugettext(" (...)") -- cgit v1.2.3