From 1eafc9f945ab4be23e6c0f22577705d2e04a8a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 7 Feb 2025 14:33:34 +0100 Subject: [PATCH] [MIG] mail_notification_custom_subject: Migration to 18.0 TT54190 --- mail_notification_custom_subject/README.rst | 20 +- .../__manifest__.py | 4 +- mail_notification_custom_subject/i18n/es.po | 10 - .../i18n/es_ES.po | 155 -------------- mail_notification_custom_subject/i18n/it.po | 7 - .../models/mail_thread.py | 13 +- .../readme/CONFIGURE.md | 4 +- .../static/description/index.html | 12 +- .../test_mail_notification_custom_subject.py | 199 +++++++++--------- ...mail_notification_custom_subject_views.xml | 6 +- 10 files changed, 131 insertions(+), 299 deletions(-) delete mode 100644 mail_notification_custom_subject/i18n/es_ES.po diff --git a/mail_notification_custom_subject/README.rst b/mail_notification_custom_subject/README.rst index 6dccd450..9dfe1757 100644 --- a/mail_notification_custom_subject/README.rst +++ b/mail_notification_custom_subject/README.rst @@ -16,14 +16,14 @@ Mail Notification Custom Subject .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github - :target: https://github.com/OCA/social/tree/17.0/mail_notification_custom_subject - :alt: OCA/social +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github + :target: https://github.com/OCA/mail/tree/18.0/mail_notification_custom_subject + :alt: OCA/mail .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_notification_custom_subject + :target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_notification_custom_subject :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -48,9 +48,9 @@ Configuration - The field **Model** specifies the model to which the subject template should apply in the notification emails sent by Odoo. - The field **Subject Template** accepts - `expressions `__. + `expressions `__. - The field **Subject to replace** accepts - `expressions `__ + `expressions `__ - The field **Replace** specifies if the template should replace existing content or append to it. - The field **Partial Replacement** specifies if the template @@ -68,10 +68,10 @@ To use this module, you need to: Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -122,6 +122,6 @@ Current `maintainer `__: |maintainer-yajo| -This module is part of the `OCA/social `_ project on GitHub. +This module is part of the `OCA/mail `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_notification_custom_subject/__manifest__.py b/mail_notification_custom_subject/__manifest__.py index cd5208f6..71686ac7 100644 --- a/mail_notification_custom_subject/__manifest__.py +++ b/mail_notification_custom_subject/__manifest__.py @@ -5,9 +5,9 @@ { "name": "Mail Notification Custom Subject", "summary": "Apply a custom subject to mail notifications", - "version": "17.0.1.2.0", + "version": "18.0.1.0.0", "category": "Social Network", - "website": "https://github.com/OCA/social", + "website": "https://github.com/OCA/mail", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, diff --git a/mail_notification_custom_subject/i18n/es.po b/mail_notification_custom_subject/i18n/es.po index 9fc61fd3..2f180607 100644 --- a/mail_notification_custom_subject/i18n/es.po +++ b/mail_notification_custom_subject/i18n/es.po @@ -139,13 +139,3 @@ msgid "" "Whether to replace completely, partially, append at beginning or append at " "end to other templates that apply to a given context" msgstr "" - -#~ msgid "" -#~ "Whether to replace, append at beggining or append at end to other " -#~ "templates that apply to a given context" -#~ msgstr "" -#~ "Si reemplazar, añadir al principio o añadir al final a otras plantillas " -#~ "que se aplican a un contexto determinado" - -#~ msgid "Last Modified on" -#~ msgstr "Última Modificación el" diff --git a/mail_notification_custom_subject/i18n/es_ES.po b/mail_notification_custom_subject/i18n/es_ES.po deleted file mode 100644 index f7002e4c..00000000 --- a/mail_notification_custom_subject/i18n/es_ES.po +++ /dev/null @@ -1,155 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * mail_notification_custom_subject -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-02-16 10:56+0000\n" -"PO-Revision-Date: 2021-02-16 11:56+0100\n" -"Last-Translator: Carlos \n" -"Language-Team: \n" -"Language: es_ES\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 2.0.6\n" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields.selection,name:mail_notification_custom_subject.selection__mail_message_custom_subject__position__append_after -msgid "Append After" -msgstr "Añadir después" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields.selection,name:mail_notification_custom_subject.selection__mail_message_custom_subject__position__append_before -msgid "Append Before" -msgstr "Añadir antes" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subtype_ids -msgid "Applied Subtypes" -msgstr "Subtipos aplicados" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__create_uid -msgid "Created by" -msgstr "Creado por" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__create_date -msgid "Created on" -msgstr "Creado el" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__display_name -msgid "Display Name" -msgstr "Nombre mostrado" - -#. module: mail_notification_custom_subject -#: model:ir.model,name:mail_notification_custom_subject.model_mail_thread -msgid "Email Thread" -msgstr "Hilo de correo electrónico" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__id -msgid "ID" -msgstr "ID" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__write_uid -msgid "Last Updated by" -msgstr "Última modificación por" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__write_date -msgid "Last Updated on" -msgstr "Última actualización el" - -#. module: mail_notification_custom_subject -#: model:ir.model,name:mail_notification_custom_subject.model_mail_message_custom_subject -msgid "Mail Message Custom Subject" -msgstr "Asunto Personalizado en Mensaje de Correo" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__model_id -msgid "Model" -msgstr "Modelo" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,help:mail_notification_custom_subject.field_mail_message_custom_subject__model_id -msgid "Model where this template applies" -msgstr "Modelo en el que se aplica la plantilla" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields.selection,name:mail_notification_custom_subject.selection__mail_message_custom_subject__position__inside_replace -msgid "Partial Replacement" -msgstr "" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__position -msgid "Position" -msgstr "Posición" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields.selection,name:mail_notification_custom_subject.selection__mail_message_custom_subject__position__replace -msgid "Replace" -msgstr "Sustituir" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,help:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template -#: model_terms:ir.ui.view,arch_db:mail_notification_custom_subject.mail_notification_custom_subject_form -msgid "Subject (placeholders may be used here)" -msgstr "Asunto (se pueden utilizar aquí expresiones de campos)" - -#. module: mail_notification_custom_subject -#: model:ir.actions.act_window,name:mail_notification_custom_subject.action_mail_notification_custom_subject_tree_all -#: model:ir.ui.menu,name:mail_notification_custom_subject.menu_mail_notification_custom_subject -#: model_terms:ir.ui.view,arch_db:mail_notification_custom_subject.mail_notification_custom_subject_form -msgid "Subject Replacement Templates" -msgstr "Plantillas de Sustitución de Asuntos" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template -#, fuzzy -msgid "Subject Template" -msgstr "Plantillas de Sustitución de Asuntos" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_to_replace -msgid "Subject To Replace" -msgstr "" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__name -#, fuzzy -msgid "Template Name" -msgstr "Plantillas" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,help:mail_notification_custom_subject.field_mail_message_custom_subject__subject_to_replace -msgid "" -"The text that will be replaced. You can use placeholders. E.g.: {{ object." -"company_id.name }}" -msgstr "" - -#. module: mail_notification_custom_subject -#: model:ir.model.fields,help:mail_notification_custom_subject.field_mail_message_custom_subject__position -msgid "" -"Whether to replace completely, partially, append at beginning or append at " -"end to other templates that apply to a given context" -msgstr "" - -#~ msgid "" -#~ "Whether to replace, append at beggining or append at end to other " -#~ "templates that apply to a given context" -#~ msgstr "" -#~ "Ya sea para reemplazar, agregar al principio o agregar al final a otras " -#~ "plantillas que se aplican a un contexto determinado" - -#~ msgid "Last Modified on" -#~ msgstr "Última modificación el" - -#~ msgid "Templates" -#~ msgstr "Plantillas" diff --git a/mail_notification_custom_subject/i18n/it.po b/mail_notification_custom_subject/i18n/it.po index bd3e794e..533bedd4 100644 --- a/mail_notification_custom_subject/i18n/it.po +++ b/mail_notification_custom_subject/i18n/it.po @@ -141,10 +141,3 @@ msgid "" msgstr "" "Se sostituire completamente, parzialmente, aggiungere all'inizio o alla fine " "di altri modelli che si applicano a un dato contesto" - -#~ msgid "" -#~ "Whether to replace, append at beggining or append at end to other " -#~ "templates that apply to a given context" -#~ msgstr "" -#~ "Se si applica ad un dato contesto la sostituzione, l'aggiunta all'inizio " -#~ "o l'aggiunta alla fine ad altri modelli" diff --git a/mail_notification_custom_subject/models/mail_thread.py b/mail_notification_custom_subject/models/mail_thread.py index 9b15aac9..c74be0d0 100644 --- a/mail_notification_custom_subject/models/mail_thread.py +++ b/mail_notification_custom_subject/models/mail_thread.py @@ -53,10 +53,15 @@ def message_post( .sudo(False) ) if not subject: - subject = "Re: %s" % self.env["mail.message"].with_context( - default_model=self._name, - default_res_id=self.id, - )._get_record_name({}) + record_name = ( + self.env["mail.message"] + .with_context( + default_model=self._name, + default_res_id=self.id, + ) + ._get_record_name({}) + ) + subject = f"Re: {record_name}" for template in custom_subjects: try: rendered_subject_template = self.env[ diff --git a/mail_notification_custom_subject/readme/CONFIGURE.md b/mail_notification_custom_subject/readme/CONFIGURE.md index 482a06d0..8f025ed0 100644 --- a/mail_notification_custom_subject/readme/CONFIGURE.md +++ b/mail_notification_custom_subject/readme/CONFIGURE.md @@ -8,9 +8,9 @@ > - The field **Model** specifies the model to which the subject > template should apply in the notification emails sent by Odoo. > - The field **Subject Template** accepts - > [expressions](https://www.odoo.com/documentation/17.0/applications/general/companies/email_template.html#dynamic-placeholders). + > [expressions](https://www.odoo.com/documentation/18.0/applications/general/companies/email_template.html#dynamic-placeholders). > - The field **Subject to replace** accepts - > [expressions](https://www.odoo.com/documentation/17.0/applications/general/companies/email_template.html#dynamic-placeholders) + > [expressions](https://www.odoo.com/documentation/18.0/applications/general/companies/email_template.html#dynamic-placeholders) > - The field **Replace** specifies if the template should replace > existing content or append to it. > - The field **Partial Replacement** specifies if the template should diff --git a/mail_notification_custom_subject/static/description/index.html b/mail_notification_custom_subject/static/description/index.html index de9224e5..8d74c454 100644 --- a/mail_notification_custom_subject/static/description/index.html +++ b/mail_notification_custom_subject/static/description/index.html @@ -369,7 +369,7 @@

Mail Notification Custom Subject

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:83cd7d0e7b75b08fb47046bf6f644f1d4477aa51d8b6f2bf4cb042cd70e84a5e !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

Production/Stable License: AGPL-3 OCA/mail Translate me on Weblate Try me on Runboat

This module allows you to specify templates to override the subject on the notification emails sent by Odoo

Table of contents

@@ -399,9 +399,9 @@

Configuration

  • The field Model specifies the model to which the subject template should apply in the notification emails sent by Odoo.
  • The field Subject Template accepts -expressions.
  • +expressions.
  • The field Subject to replace accepts -expressions
  • +expressions
  • The field Replace specifies if the template should replace existing content or append to it.
  • The field Partial Replacement specifies if the template @@ -422,10 +422,10 @@

    Usage

    Bug Tracker

    -

    Bugs are tracked on GitHub Issues. +

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -472,7 +472,7 @@

    Maintainers

    promote its widespread use.

    Current maintainer:

    yajo

    -

    This module is part of the OCA/social project on GitHub.

    +

    This module is part of the OCA/mail project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py b/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py index a1e2bfe7..3ea48855 100644 --- a/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py +++ b/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py @@ -1,8 +1,8 @@ # Copyright 2020 Tecnativa - João Marques -# Copyright 2022 Tecnativa - Víctor Martínez +# Copyright 2022-2025 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -# pylint: disable=C8107 from odoo.tests import new_test_user +from odoo.tests.common import users from odoo.tools import mute_logger from odoo.addons.base.tests.common import BaseCommon @@ -19,21 +19,19 @@ def setUpClass(cls): ] ) cls.admin = new_test_user(cls.env, "boss", "base.group_system") + new_test_user(cls.env, "worker_custom_subject") + cls.subject_model = cls.env["mail.message.custom.subject"].with_user(cls.admin) - def setUp(self): - super().setUp() - self.uid = new_test_user(self.env, "worker") - + @users("worker_custom_subject") def test_email_subject_template_overrides(self): - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 1", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{object.name or 'n/a'}} and something more", - } - ) + self.subject_model.create( + { + "name": "Test template 1", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{object.name or 'n/a'}} and something more", + } + ) # Send message in partner mail_message_1 = self.partner_1.message_post( body="Test", subtype_xmlid="mail.mt_comment" @@ -55,18 +53,18 @@ def test_email_subject_template_overrides(self): # Get message and check subject self.assertEqual(mail_message_3.subject, "Test") + @users("worker_custom_subject") def test_email_subject_template_inside_replace(self): - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_to_replace": "{{object.company_id.name}}", - "subject_template": "CLN", - "position": "inside_replace", - } - ) + self.subject_model.create( + { + "name": "Test template", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_to_replace": "{{object.company_id.name}}", + "subject_template": "CLN", + "position": "inside_replace", + } + ) self.partner_1.company_id = self.env.company self.partner_1.company_id.name = "COMPANY_LONG_NAME" mail_message_1 = self.partner_1.message_post( @@ -76,16 +74,16 @@ def test_email_subject_template_inside_replace(self): ) self.assertEqual(mail_message_1.subject, "CLN: Custom") + @users("worker_custom_subject") def test_email_subject_template_normal(self): - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 1", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{object.name or 'n/a'}} and something more", - } - ) + self.subject_model.create( + { + "name": "Test template 1", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{object.name or 'n/a'}} and something more", + } + ) # Send note in partner mail_message_1 = self.partner_1.message_post( body="Test", subtype_xmlid="mail.mt_note", subject="Test" @@ -93,26 +91,25 @@ def test_email_subject_template_normal(self): # Get message and check subject. Subject Template should not apply self.assertEqual(mail_message_1.subject, "Test") + @users("worker_custom_subject") def test_email_subject_template_multi(self): - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 1", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{object.name or 'n/a'}} and something more", - } - ) - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 2", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{object.name or 'n/a'}} and " - "something different", - } - ) + self.subject_model.create( + { + "name": "Test template 1", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{object.name or 'n/a'}} and something more", + } + ) + self.subject_model.create( + { + "name": "Test template 2", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{object.name or 'n/a'}} and " + "something different", + } + ) # Send message in partner mail_message_1 = self.partner_1.message_post( body="Test", subtype_xmlid="mail.mt_comment" @@ -121,16 +118,15 @@ def test_email_subject_template_multi(self): self.assertEqual( mail_message_1.subject, "Test partner 1 and something different" ) - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 3", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{' and yet something else'}}", - "position": "append_after", - } - ) + self.subject_model.create( + { + "name": "Test template 3", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{' and yet something else'}}", + "position": "append_after", + } + ) # Send message in partner mail_message_2 = self.partner_1.message_post( body="Test", subtype_xmlid="mail.mt_comment" @@ -140,16 +136,15 @@ def test_email_subject_template_multi(self): mail_message_2.subject, "Test partner 1 and something different and yet something else", ) - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 4", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{'Re: '}}", - "position": "append_before", - } - ) + self.subject_model.create( + { + "name": "Test template 4", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{'Re: '}}", + "position": "append_before", + } + ) # Send message in partner mail_message_3 = self.partner_1.message_post( body="Test", subtype_xmlid="mail.mt_comment" @@ -160,17 +155,17 @@ def test_email_subject_template_multi(self): "Re: Test partner 1 and something different and yet something else", ) + @users("worker_custom_subject") def test_email_subject_template_w_original(self): - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test template 1", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{' and something more'}}", - "position": "append_after", - } - ) + self.subject_model.create( + { + "name": "Test template 1", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{' and something more'}}", + "position": "append_after", + } + ) # Send message in partner mail_message_1 = self.partner_1.message_post( body="Test", @@ -180,29 +175,33 @@ def test_email_subject_template_w_original(self): # Get message and check subject self.assertEqual(mail_message_1.subject, "Test and something more") + @users("worker_custom_subject") + @mute_logger( + "odoo.addons.mail.models.mail_render_mixin", + "odoo.addons.mail_notification_custom_subject.models.mail_thread", + ) def test_bad_template_does_not_break(self): """Create template with error (obaject) to test error.""" - with self.with_user("boss"): - self.env["mail.message.custom.subject"].create( - { - "name": "Test bad template 1", - "model_id": self.env.ref("base.model_res_partner").id, - "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], - "subject_template": "{{obaject.number_a}} and something", - "position": "append_after", - } - ) + self.subject_model.create( + { + "name": "Test bad template 1", + "model_id": self.env.ref("base.model_res_partner").id, + "subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])], + "subject_template": "{{obaject.number_a}} and something", + "position": "append_after", + } + ) # Send message in partner - with mute_logger("odoo.addons.mail.models.mail_render_mixin"): - mail_message_1 = self.partner_1.message_post( - body="Test", - subtype_xmlid="mail.mt_comment", - subject="Test", - ) + mail_message_1 = self.partner_1.message_post( + body="Test", + subtype_xmlid="mail.mt_comment", + subject="Test", + ) # Get message and check subject # No exception should be raised but subject should remain as original. self.assertEqual(mail_message_1.subject, "Test") + @users("worker_custom_subject") def test_no_template_default_result(self): # Send message in partner mail_message_1 = self.partner_1.message_post( diff --git a/mail_notification_custom_subject/views/mail_notification_custom_subject_views.xml b/mail_notification_custom_subject/views/mail_notification_custom_subject_views.xml index 3285ac57..eb57e6f8 100644 --- a/mail_notification_custom_subject/views/mail_notification_custom_subject_views.xml +++ b/mail_notification_custom_subject/views/mail_notification_custom_subject_views.xml @@ -34,12 +34,12 @@ mail.message.custom.subject.tree mail.message.custom.subject - + - + Subject Replacement Templates mail.message.custom.subject - form,tree + form,list