diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/utils.py | 13 | 
1 files changed, 10 insertions, 3 deletions
| diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 44112bca3..9b3c85694 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -60,11 +60,18 @@ def cached_label_changed(sender, **kwargs):              and instance._cached_label_checked:          return      instance._cached_label_checked = True -    lbl = instance._generate_cached_label() -    if lbl != instance.cached_label: +    cached_labels = ['cached_label'] +    if hasattr(sender, 'CACHED_LABELS'): +        cached_labels = sender.CACHED_LABELS +    changed = False +    for cached_label in cached_labels: +        lbl = getattr(instance, '_generate_' + cached_label)() +        if lbl != getattr(instance, cached_label): +            setattr(instance, cached_label, lbl) +            changed = True +    if changed:          if hasattr(instance, '_cascade_change') and instance._cascade_change:              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(): | 
