From d8decb491a4dec2a49e701220b616c51463f78fb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 5 Jul 2023 11:20:43 +0200 Subject: 🐛 check of external identifiers when updating cached labels (refs #5603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index c6c14422c..673821c14 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -544,6 +544,7 @@ def load_task(task_func, task_name, checks, sender, **kwargs): def cached_label_changed(sender, **kwargs): + load_task(_external_id_changed, "external_id_changed", None, sender, **kwargs) return load_task(_cached_label_changed, "cached_label_changed", None, sender, **kwargs) @@ -633,7 +634,8 @@ def external_id_changed(sender, **kwargs): @task() def _external_id_changed(sender, **kwargs): sender, instance = deserialize_args_for_tasks(sender, kwargs, EXTRA_KWARGS_TRIGGER) - if not instance: + if not instance or not hasattr(instance, "external_id") \ + or not hasattr(instance, "auto_external_id"): return updated = False instance.no_post_process() @@ -643,12 +645,12 @@ def _external_id_changed(sender, **kwargs): updated = True instance.auto_external_id = True instance.external_id = external_id - updated |= instance.regenerate_all_ids(save=False) + if hasattr(instance, "regenerate_all_ids"): + updated |= instance.regenerate_all_ids(save=False) or False if updated: instance.save() - def shortify(lbl, number=20): SHORTIFY_STR = ugettext(" (...)") if not lbl: -- cgit v1.2.3