From ce4d3b0683530b7f8f7ef7d3eeee174e7507999b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Alan=20Ramos=20Rodri=CC=81guez?= Date: Tue, 29 Aug 2023 07:52:47 -0600 Subject: [PATCH] [IMP] base_comment_template: allow to select rendering engine in comment template --- base_comment_template/models/base_comment_template.py | 10 ++++++++++ base_comment_template/models/comment_template.py | 4 ++-- .../views/base_comment_template_view.xml | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/base_comment_template/models/base_comment_template.py b/base_comment_template/models/base_comment_template.py index 09f7f2fe0..37c0a5f54 100644 --- a/base_comment_template/models/base_comment_template.py +++ b/base_comment_template/models/base_comment_template.py @@ -72,6 +72,16 @@ class BaseCommentTemplate(models.Model): sequence = fields.Integer( required=True, default=10, help="The smaller number = The higher priority" ) + engine = fields.Selection( + selection=[ + ("inline_template", "Inline Template"), + ("qweb", "QWeb"), + ("qweb_view", "QWeb View"), + ], + required=True, + default="inline_template", + help="This field allows to select the engine to use for rendering the template.", + ) def _get_ir_model_items(self, models): return ( diff --git a/base_comment_template/models/comment_template.py b/base_comment_template/models/comment_template.py index 64afe3980..63a34decd 100644 --- a/base_comment_template/models/comment_template.py +++ b/base_comment_template/models/comment_template.py @@ -50,14 +50,14 @@ class CommentTemplate(models.AbstractModel): record.comment_template_ids = [(4, template.id)] def render_comment( - self, comment, engine="inline_template", add_context=None, post_process=False + self, comment, engine=False, add_context=None, post_process=False ): self.ensure_one() comment_texts = self.env["mail.render.mixin"]._render_template( template_src=comment.text, model=self._name, res_ids=[self.id], - engine=engine, + engine=engine or comment.engine, add_context=add_context, post_process=post_process, ) diff --git a/base_comment_template/views/base_comment_template_view.xml b/base_comment_template/views/base_comment_template_view.xml index 50964fe60..8fa523737 100644 --- a/base_comment_template/views/base_comment_template_view.xml +++ b/base_comment_template/views/base_comment_template_view.xml @@ -71,6 +71,7 @@ +