diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 3538db2f8..c295e40ac 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1604,12 +1604,13 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem, finds__upstream_treatment_id__isnull=True, finds__base_finds__context_record__operation=self)] for q in qs: - for res in q.values('source_type').distinct(): - st = res['source_type'] + for st in set(q.values_list('source_type_id', + flat=True).distinct()): if st not in docs: docs[st] = 0 - docs[st] += q.filter(source_type=st).count() - docs = [(str(SourceType.objects.get(pk=k)), docs[k]) for k in docs] + docs[st] += q.filter(source_type_id=st).count() + docs = [(str(SourceType.objects.get(pk=k)) + if k else str(_("No type")), docs[k]) for k in docs] return list(sorted(docs, key=lambda x: x[0])) @property |