Skip to content

Commit dccbaa6

Browse files
committed
fix: to fixes for exports
1 parent a596058 commit dccbaa6

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

backend/application/commons/services/export.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def export_excel(objects: QuerySet, title: str, excludes: list[str], foreign_key
6060
value = str(getattr(current_object, key))
6161
if value and isinstance(value, datetime):
6262
value = value.replace(tzinfo=None)
63+
if value and (isinstance(value, list) or isinstance(value, dict)):
64+
value = str(value)
6365
value = _escape_formula(value)
6466
try:
6567
worksheet.cell(row=row_num, column=col_num, value=value)

backend/application/core/services/export_observations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from application.commons.services.export import export_csv, export_excel
99
from application.core.models import Observation, Observation_Log, Product
10+
from application.core.types import Observation_Log_Comment
1011

1112

1213
def export_observations_excel(observations: QuerySet) -> Workbook:
@@ -33,6 +34,7 @@ def _annotate_observation_log_comment(observations: QuerySet) -> QuerySet:
3334
newest_comment = Subquery(
3435
Observation_Log.objects.filter(observation=OuterRef("pk"))
3536
.filter(~Q(severity="") | ~Q(status=""))
37+
.exclude(comment__in=Observation_Log_Comment.AUTOMATED_COMMENTS)
3638
.order_by("-created", "-id")
3739
.values("comment")[:1]
3840
)

0 commit comments

Comments
 (0)