diff --git a/base_comment_template/README.rst b/base_comment_template/README.rst index e2016370d..a6dd4f38d 100644 --- a/base_comment_template/README.rst +++ b/base_comment_template/README.rst @@ -83,7 +83,7 @@ Usage You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one. If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one. -The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content. +The template is a html field which will be rendered just like a mail template, so you can use variables like {{object}}, {{user}}, {{ctx}} to add dynamic content. Change the report related to the model from configuration and add a statement like: @@ -103,7 +103,7 @@ You should always use t-if since the method returns False if no template is foun If you want to use Qweb templates, or different context, you can specify it just like in mail.render.mixin with parameters: -- engine: "jinja" or "qweb", +- engine: "inline_template", "qweb" or "qweb_view", - add_context: dict with your own context, - post_process: perform a post processing on rendered result diff --git a/base_comment_template/__init__.py b/base_comment_template/__init__.py index ba0a966ff..f987065d3 100644 --- a/base_comment_template/__init__.py +++ b/base_comment_template/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import models, wizard +from . import models +from . import wizard diff --git a/base_comment_template/i18n/de.po b/base_comment_template/i18n/de.po index a04d6d4d0..be50e563c 100644 --- a/base_comment_template/i18n/de.po +++ b/base_comment_template/i18n/de.po @@ -344,26 +344,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Suffix" - -#~ msgid "Base comment template" -#~ msgstr "Textbausteinvorlage" - -#~ msgid "Before lines" -#~ msgstr "Präfix" - -#~ msgid "Comment summary" -#~ msgstr "Textbaustein-Zusammenfassung" - -#~ msgid "Conditions template" -#~ msgstr "Textbausteinvorlage" - -#~ msgid "If set, it'll only be available for this company" -#~ msgstr "" -#~ "Wenn der Haken gesetzt ist, ist die Vorlage nur das gesetzte Unternehmen " -#~ "verfügbar." - -#~ msgid "Position" -#~ msgstr "Position" diff --git a/base_comment_template/i18n/es.po b/base_comment_template/i18n/es.po index 7530437e1..29714bbf8 100644 --- a/base_comment_template/i18n/es.po +++ b/base_comment_template/i18n/es.po @@ -355,32 +355,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Después de las líneas" - -#~ msgid "Before lines" -#~ msgstr "Antes de las líneas" - -#~ msgid "Priority" -#~ msgstr "Prioridad" - -#~ msgid "" -#~ "There are other records with same models, priority, domain and position." -#~ msgstr "" -#~ "Hay otros registros con los mismos datos en modelo, prioridad, dominio y " -#~ "posición." - -#~ msgid "the highest priority = the smallest number" -#~ msgstr "Mayor prioridad = número menor" - -#~ msgid "Comment summary" -#~ msgstr "Índice de comentarios" - -#, fuzzy -#~| msgid "Comment Templates" -#~ msgid "Conditions template" -#~ msgstr "Plantillas de comentarios" - -#~ msgid "Position" -#~ msgstr "Posició" diff --git a/base_comment_template/i18n/fr.po b/base_comment_template/i18n/fr.po index 9df9dc3a2..6ebe1436c 100644 --- a/base_comment_template/i18n/fr.po +++ b/base_comment_template/i18n/fr.po @@ -342,22 +342,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Après les lignes" - -#~ msgid "Base comment template" -#~ msgstr "Modèle de textes de commentaires" - -#~ msgid "Before lines" -#~ msgstr "Avant les lignes" - -#~ msgid "Comment summary" -#~ msgstr "Nom" - -#, fuzzy -#~ msgid "Conditions template" -#~ msgstr "Modèles de commentaires" - -#~ msgid "Position" -#~ msgstr "Position" diff --git a/base_comment_template/i18n/gl.po b/base_comment_template/i18n/gl.po index d6624cd5e..584bdd05b 100644 --- a/base_comment_template/i18n/gl.po +++ b/base_comment_template/i18n/gl.po @@ -343,22 +343,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Despois das liñas" - -#~ msgid "Base comment template" -#~ msgstr "Modelo do comentario base" - -#~ msgid "Before lines" -#~ msgstr "Antes das liñas" - -#~ msgid "Comment summary" -#~ msgstr "Índice de comentarios" - -#, fuzzy -#~ msgid "Conditions template" -#~ msgstr "Modelos de comentarios" - -#~ msgid "Position" -#~ msgstr "Posición" diff --git a/base_comment_template/i18n/hr.po b/base_comment_template/i18n/hr.po index f14f2416b..6d52b7f24 100644 --- a/base_comment_template/i18n/hr.po +++ b/base_comment_template/i18n/hr.po @@ -345,21 +345,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Iza linija" - -#~ msgid "Base comment template" -#~ msgstr "Osnovni Predložak komentara" - -#~ msgid "Before lines" -#~ msgstr "Ispred linija" - -#~ msgid "Comment summary" -#~ msgstr "Sažetak komentara" - -#~ msgid "Conditions template" -#~ msgstr "Predložak uvjeta" - -#~ msgid "Position" -#~ msgstr "Pozicija" diff --git a/base_comment_template/i18n/it.po b/base_comment_template/i18n/it.po index e2b0844ef..6accf86a6 100644 --- a/base_comment_template/i18n/it.po +++ b/base_comment_template/i18n/it.po @@ -358,6 +358,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "Position" -#~ msgstr "Posizione" diff --git a/base_comment_template/i18n/ja.po b/base_comment_template/i18n/ja.po index cbe0cdcbe..51ff73eaa 100644 --- a/base_comment_template/i18n/ja.po +++ b/base_comment_template/i18n/ja.po @@ -343,22 +343,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "明細行後" - -#~ msgid "Base comment template" -#~ msgstr "Base comment template" - -#~ msgid "Before lines" -#~ msgstr "明細行前" - -#~ msgid "Comment summary" -#~ msgstr "コメントサマリ" - -#, fuzzy -#~ msgid "Conditions template" -#~ msgstr "コメントテンプレート" - -#~ msgid "Position" -#~ msgstr "位置" diff --git a/base_comment_template/i18n/pt.po b/base_comment_template/i18n/pt.po index c5b2bd7e9..f836e2287 100644 --- a/base_comment_template/i18n/pt.po +++ b/base_comment_template/i18n/pt.po @@ -356,24 +356,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Após as linhas" - -#~ msgid "Base comment template" -#~ msgstr "Modelo de Comentários Base" - -#~ msgid "Before lines" -#~ msgstr "Antes das Linhas" - -#~ msgid "Comment summary" -#~ msgstr "Resumo de comentário" - -#~ msgid "Conditions template" -#~ msgstr "Modelos de condições" - -#~ msgid "If set, it'll only be available for this company" -#~ msgstr "Se assinalado, só estará disponível para esta empresa" - -#~ msgid "Position" -#~ msgstr "Posição" diff --git a/base_comment_template/i18n/pt_BR.po b/base_comment_template/i18n/pt_BR.po index dc9fbe4a8..9cd2858df 100644 --- a/base_comment_template/i18n/pt_BR.po +++ b/base_comment_template/i18n/pt_BR.po @@ -344,24 +344,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Depois das linhas" - -#~ msgid "Base comment template" -#~ msgstr "Modelo de comentário Base" - -#~ msgid "Before lines" -#~ msgstr "Antes das linhas" - -#~ msgid "Comment summary" -#~ msgstr "Índice de comentários" - -#~ msgid "Conditions template" -#~ msgstr "Modelos de condições" - -#~ msgid "If set, it'll only be available for this company" -#~ msgstr "Se definido, ele estará disponível apenas para esta empresa" - -#~ msgid "Position" -#~ msgstr "Posição" diff --git a/base_comment_template/i18n/pt_PT.po b/base_comment_template/i18n/pt_PT.po index 56b3f1fce..27f5d1f70 100644 --- a/base_comment_template/i18n/pt_PT.po +++ b/base_comment_template/i18n/pt_PT.po @@ -344,24 +344,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Após as linhas" - -#~ msgid "Base comment template" -#~ msgstr "Modelo de comentários base" - -#~ msgid "Before lines" -#~ msgstr "Antes das linhas" - -#~ msgid "Comment summary" -#~ msgstr "Resumo de comentários" - -#~ msgid "Conditions template" -#~ msgstr "Modelo de condições" - -#~ msgid "If set, it'll only be available for this company" -#~ msgstr "Se assinalado, será apenas visível para esta empresa" - -#~ msgid "Position" -#~ msgstr "Posição" diff --git a/base_comment_template/i18n/sk.po b/base_comment_template/i18n/sk.po index bc3a81d17..8b856fd64 100644 --- a/base_comment_template/i18n/sk.po +++ b/base_comment_template/i18n/sk.po @@ -343,24 +343,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Za položkami" - -#~ msgid "Base comment template" -#~ msgstr "Základná šablóna komentárov" - -#~ msgid "Before lines" -#~ msgstr "Pred položkami" - -#~ msgid "Comment summary" -#~ msgstr "Názov" - -#~ msgid "Conditions template" -#~ msgstr "Predvolená šablóna" - -#~ msgid "If set, it'll only be available for this company" -#~ msgstr "Ak je nastavená, bude k dispozícii iba pre túto spoločnosť" - -#~ msgid "Position" -#~ msgstr "Pozícia" diff --git a/base_comment_template/i18n/sl.po b/base_comment_template/i18n/sl.po index 6065b1f2d..e0dc6c52f 100644 --- a/base_comment_template/i18n/sl.po +++ b/base_comment_template/i18n/sl.po @@ -344,22 +344,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:base_comment_template.base_comment_template_preview_form msgid "record:" msgstr "" - -#~ msgid "After lines" -#~ msgstr "Po postavkah" - -#~ msgid "Base comment template" -#~ msgstr "Osnovna predloga za komentarje" - -#~ msgid "Before lines" -#~ msgstr "Pred postavkami" - -#~ msgid "Comment summary" -#~ msgstr "Povzetek komentarjev" - -#, fuzzy -#~ msgid "Conditions template" -#~ msgstr "Predloge komentarjev" - -#~ msgid "Position" -#~ msgstr "Položaj" diff --git a/base_comment_template/migrations/15.0.1.0.0/post-migration.py b/base_comment_template/migrations/15.0.1.0.0/post-migration.py new file mode 100644 index 000000000..fe9f2f703 --- /dev/null +++ b/base_comment_template/migrations/15.0.1.0.0/post-migration.py @@ -0,0 +1,17 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import re + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + """In v15 mail engine is inline_template, we try to replace the following: + - ${object} > {{object}} + - ${user} > {{user}} + - ${ctx} > {{ctx}} + """ + for item in env["base.comment.template"].search([("text", "ilike", "${")]): + item.text = re.sub(r"\${(.+)}", r"{{\1}}", item.text) diff --git a/base_comment_template/models/__init__.py b/base_comment_template/models/__init__.py index 9ac817697..385ad1d18 100644 --- a/base_comment_template/models/__init__.py +++ b/base_comment_template/models/__init__.py @@ -1 +1,4 @@ -from . import base_comment_template, comment_template, ir_model, res_partner +from . import base_comment_template +from . import comment_template +from . import ir_model +from . import res_partner diff --git a/base_comment_template/models/comment_template.py b/base_comment_template/models/comment_template.py index befd11cd0..b421eadc1 100644 --- a/base_comment_template/models/comment_template.py +++ b/base_comment_template/models/comment_template.py @@ -44,13 +44,13 @@ class CommentTemplate(models.AbstractModel): record.comment_template_ids = [(4, template.id)] def render_comment( - self, comment, engine="jinja", add_context=None, post_process=False + self, comment, engine="inline_template", add_context=None, post_process=False ): self.ensure_one() comment_texts = self.env["mail.render.mixin"]._render_template( - comment.text, - self._name, - [self.id], + template_src=comment.text, + model=self._name, + res_ids=[self.id], engine=engine, add_context=add_context, post_process=post_process, diff --git a/base_comment_template/models/ir_model.py b/base_comment_template/models/ir_model.py index b799732b0..85a35343b 100644 --- a/base_comment_template/models/ir_model.py +++ b/base_comment_template/models/ir_model.py @@ -14,7 +14,7 @@ class IrModel(models.Model): ) def _reflect_model_params(self, model): - vals = super(IrModel, self)._reflect_model_params(model) + vals = super()._reflect_model_params(model) vals["is_comment_template"] = issubclass( type(model), self.pool["comment.template"] ) @@ -22,7 +22,7 @@ class IrModel(models.Model): @api.model def _instanciate(self, model_data): - model_class = super(IrModel, self)._instanciate(model_data) + model_class = super()._instanciate(model_data) if ( model_data.get("is_comment_template") and model_class._name != "comment.template" diff --git a/base_comment_template/readme/USAGE.rst b/base_comment_template/readme/USAGE.rst index 5c7d46bc8..8800f0741 100644 --- a/base_comment_template/readme/USAGE.rst +++ b/base_comment_template/readme/USAGE.rst @@ -12,7 +12,7 @@ You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one. If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one. -The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content. +The template is a html field which will be rendered just like a mail template, so you can use variables like {{object}}, {{user}}, {{ctx}} to add dynamic content. Change the report related to the model from configuration and add a statement like: @@ -32,7 +32,7 @@ You should always use t-if since the method returns False if no template is foun If you want to use Qweb templates, or different context, you can specify it just like in mail.render.mixin with parameters: -- engine: "jinja" or "qweb", +- engine: "inline_template", "qweb" or "qweb_view", - add_context: dict with your own context, - post_process: perform a post processing on rendered result diff --git a/base_comment_template/static/description/index.html b/base_comment_template/static/description/index.html index cf5471d59..ec7ec6185 100644 --- a/base_comment_template/static/description/index.html +++ b/base_comment_template/static/description/index.html @@ -431,7 +431,7 @@ It has a priority field (smaller number = higher priority)
You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one. If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.
-The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.
+The template is a html field which will be rendered just like a mail template, so you can use variables like {{object}}, {{user}}, {{ctx}} to add dynamic content.
Change the report related to the model from configuration and add a statement like:
If you want to use Qweb templates, or different context, you can specify it just like in mail.render.mixin with parameters: