# HG changeset patch
# User Balde Oury <oury.balde@xcg-consulting.fr>
# Date 1739198317 0
#      Mon Feb 10 14:38:37 2025 +0000
# Branch 18.0
# Node ID 09936973017d99f8d810878741726b7d5940b2ad
# Parent  074376c8302c201c35eeee97f1a668e9a3472f44
Update composer value based on template counterpart for Redner integration

Enhance _set_value_from_template to support Redner integration

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,11 @@
 Changelog
 =========
 
+18.0.1.2.2
+----------
+
+Improve _set_value_from_template for redner integration.
+
 18.0.1.2.1
 ----------
 
diff --git a/__manifest__.py b/__manifest__.py
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -21,7 +21,7 @@
 {
     "name": "Redner",
     "license": "AGPL-3",
-    "version": "18.0.1.2.1",
+    "version": "18.0.1.2.2",
     "category": "Reporting",
     "author": "XCG Consulting",
     "website": "https://orbeet.io/",
diff --git a/wizard/mail_compose_message.py b/wizard/mail_compose_message.py
--- a/wizard/mail_compose_message.py
+++ b/wizard/mail_compose_message.py
@@ -6,23 +6,26 @@
 
     is_redner_template = fields.Boolean(related="template_id.is_redner_template")
 
-    def get_mail_values(self, res_ids):
-        """
-        Overrides the get_mail_values method to enhance email value retrieval
-        based on mass mail mode and redner template.
-        """
-        all_mail_values = super().get_mail_values(res_ids)
-        mass_mail_mode = self.composition_mode == "mass_mail"
+    def _set_value_from_template(self, template_fname, composer_fname=False):
+        """Override: Set composer value from its template counterpart, considering
+        redner integration."""
+        self.ensure_one()
+        composer_fname = composer_fname or template_fname
+
+        res = super()._set_value_from_template(
+            template_fname, composer_fname=composer_fname
+        )
 
-        # Check if in mass mail mode and if redner template exists
-        if mass_mail_mode and self.model and self.template_id.is_redner_template:
-            template_values = self.generate_email_for_composer(
-                self.template_id.id, res_ids, ["body_html"]
-            )
+        if self.is_redner_template and template_fname == "body_html":
+            if self.composition_mode == "comment" and not self.composition_batch:
+                res_ids = self._evaluate_res_ids()
+                rendering_res_ids = res_ids or [0]  # Fallback to dummy ID
 
-            # Update email values with rendered content
-            for res_id in res_ids:
-                body = template_values[res_id]["body"]
-                all_mail_values[res_id].update({"body": body, "body_html": body})
+                template_rendered = self.template_id._patch_email_values(
+                    {composer_fname: {}}, rendering_res_ids[0]
+                )[composer_fname]
 
-        return all_mail_values
+                self[composer_fname] = template_rendered
+                return self[composer_fname]
+
+        return res