From e7c1f8b74f92778f16721a6ad358f4f248f2a9f6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 14 Feb 2025 15:56:05 +0100 Subject: 🐛 fix VALUES serialization for preventive archaeological files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 688197c73..abff81056 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -93,6 +93,7 @@ from ishtar_common.utils import ( task, generate_pdf_preview, revoke_old_task, + InlineClass ) from ishtar_common.utils_secretary import IshtarSecretaryRenderer @@ -138,6 +139,7 @@ from ishtar_common.utils import ( cached_label_changed, generate_relation_graph, max_size_help, + JSON_SERIALIZATION ) from ishtar_common.models_common import ( @@ -2324,6 +2326,12 @@ class DocumentTemplate(models.Model): filtr = [] values = c_object.get_values(filtr=filtr) if not filtr or "VALUES" in filtr: + for k in values: + if k in JSON_SERIALIZATION: + values[k] = JSON_SERIALIZATION[k](values[k]) + elif values[k] and isinstance(values[k], list) \ + and hasattr(values[k][0], "toJSON"): + values[k] = [v.toJSON() for v in values[k]] values["VALUES"] = json.dumps( values, indent=4, -- cgit v1.2.3