From 36b43a44cd69e1b947097c9d3c1beb39024a5e41 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 Sep 2019 23:19:00 +0200 Subject: Fix "labels" shortcut display for finds and treatments --- ishtar_common/models.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c0ac5004f..2a50533db 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2039,14 +2039,16 @@ class TemplateItem: @classmethod def _label_templates_q(cls): model_name = "{}.{}".format( - cls.__module__, cls.__name__).replace( + cls.__module__, cls.__name__) + q = Q(associated_model__klass=model_name, + for_labels=True, available=True) + alt_model_name = model_name.replace( "models_finds", "models").replace( "models_treatments", "models") - return DocumentTemplate.objects.filter( - associated_model__klass=model_name, - for_labels=True, - available=True - ) + if alt_model_name != model_name: + q |= Q(associated_model__klass=model_name, + for_labels=True, available=True) + return DocumentTemplate.objects.filter(q) @classmethod def has_label_templates(cls): -- cgit v1.2.3