diff --git a/mail_notification_custom_subject/README.rst b/mail_notification_custom_subject/README.rst new file mode 100644 index 000000000..49b99d8c0 --- /dev/null +++ b/mail_notification_custom_subject/README.rst @@ -0,0 +1,135 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================ +Mail Notification Custom Subject +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9529c3d98aeed27dd9b25bf12787be628ef15efc44bc0b2c13171f73d0137c24 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/license-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%2Fmail-lightgray.png?logo=github + :target: https://github.com/OCA/mail/tree/19.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/mail-19-0/mail-19-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/mail&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to specify templates to override the subject on +the notification emails sent by Odoo + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +- Activate access to **Technical Features** (debug mode). + +- Go to **Settings > Technical > Email > Subject Replacement Templates** + +- Create a new template. + + - 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 `__. + - The field **Subject to replace** accepts + `expressions `__ + - The field **Replace** specifies if the template should replace + existing content or append to it. + - The field **Partial Replacement** specifies if the template + should parcial replace existing content. + +Usage +===== + +To use this module, you need to: + +- Open the chatter in Odoo (e.g. Open an Invoice). +- Send a message. +- Observe the rendered Subject template. + +Bug Tracker +=========== + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- Tecnativa + + - Pedro M. Baeza + - João Marques + - Carlos Roca + - Víctor Martínez + +- Versada + + - Naglis Jonaitis + +- Moduon + + - Eduardo de Miguel + +- Codeforward + + - Sander Lienaerts + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px + :target: https://github.com/yajo + :alt: yajo + +Current `maintainer `__: + +|maintainer-yajo| + +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/__init__.py b/mail_notification_custom_subject/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mail_notification_custom_subject/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_notification_custom_subject/__manifest__.py b/mail_notification_custom_subject/__manifest__.py new file mode 100644 index 000000000..331edcda6 --- /dev/null +++ b/mail_notification_custom_subject/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2020-2021 Tecnativa - João Marques +# Copyright 2021 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Mail Notification Custom Subject", + "summary": "Apply a custom subject to mail notifications", + "version": "19.0.1.0.0", + "category": "Social Network", + "website": "https://github.com/OCA/mail", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["mail"], + "data": [ + "security/ir.model.access.csv", + "views/mail_notification_custom_subject_views.xml", + ], + "development_status": "Production/Stable", + "maintainers": ["yajo"], +} diff --git a/mail_notification_custom_subject/i18n/es.po b/mail_notification_custom_subject/i18n/es.po new file mode 100644 index 000000000..9b9f52b9f --- /dev/null +++ b/mail_notification_custom_subject/i18n/es.po @@ -0,0 +1,143 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_notification_custom_subject +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-05-07 18:19+0000\n" +"Last-Translator: Ed-Spain \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\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 de" + +#. 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 "Mostrar Nombre" + +#. 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 (identificación)" + +#. 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 "Actualizado por Última vez 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 "Mensaje de correo Asunto personalizado" + +#. 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 al que se aplica esta 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 "Reemplazo parcial" + +#. 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 "Reemplazar" + +#. 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 (pueden utilizarse marcadores de posición)" + +#. 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 Temas" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template +msgid "Subject Template" +msgstr "Tema Plantilla" + +#. 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 "Asunto a reemplazar" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__name +msgid "Template Name" +msgstr "Nombre de Plantilla" + +#. 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 "" +"El texto que se reemplazará. Puede utilizar marcadores de posición. Por " +"ejemplo: {{ object.company_id.name }}" + +#. 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 "" +"Si reemplazar completamente, parcialmente, añadir al principio o al final a " +"otras plantillas que se aplican a un contexto dado" diff --git a/mail_notification_custom_subject/i18n/fr.po b/mail_notification_custom_subject/i18n/fr.po new file mode 100644 index 000000000..249662bab --- /dev/null +++ b/mail_notification_custom_subject/i18n/fr.po @@ -0,0 +1,143 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_notification_custom_subject +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-09 16:23+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.15.2\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 "Ajouter aprè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 "Ajouter avant" + +#. 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 "Sous-type concernés" + +#. 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 "Créé par" + +#. 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 "Créé le" + +#. 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 "Nom affiché" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_thread +msgid "Email Thread" +msgstr "Discussion par courriel" + +#. 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 "Modifié par" + +#. 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 "Modifié le" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_message_custom_subject +msgid "Mail Message Custom Subject" +msgstr "Sujet personnalisé du courrier" + +#. 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 "Modèle" + +#. 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 "Objet sur lequel ce modèle s'applique" + +#. 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 "Remplacement partiel" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__position +msgid "Position" +msgstr "Position" + +#. 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 "Remplacer" + +#. 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 "Sujet (des variables peuvent être utilisées ici)" + +#. 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 "Modèles de remplacement de sujet" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template +msgid "Subject Template" +msgstr "Modèle de sujet" + +#. 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 "Sujet à remplacer" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__name +msgid "Template Name" +msgstr "Nom du modèle" + +#. 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 "" +"Le texte à remplacer. Vous pouvez utiliser des variables de remplacement. ex " +": {{ object.company_id.name }}" + +#. 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 "" +"S'il faut remplacer entièrement, partiellement, ajouter au début ou ajouter " +"à la fin d'autres modèles applicables à un contexte donné" diff --git a/mail_notification_custom_subject/i18n/it.po b/mail_notification_custom_subject/i18n/it.po new file mode 100644 index 000000000..533bedd48 --- /dev/null +++ b/mail_notification_custom_subject/i18n/it.po @@ -0,0 +1,143 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_notification_custom_subject +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-02-03 22:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\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 "Appendi dopo" + +#. 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 "Appendi prima" + +#. 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 "Sotto tipi applicati" + +#. 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 "Creato da" + +#. 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 "Creato il" + +#. 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 "Nome visualizzato" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_thread +msgid "Email Thread" +msgstr "Discussione e-mail" + +#. 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 "Ultimo aggiornamento di" + +#. 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 "Ultimo aggiornamento il" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_message_custom_subject +msgid "Mail Message Custom Subject" +msgstr "Oggetto perconalizzato messaggio e-mail" + +#. 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 "Modello" + +#. 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 "Modello dove si applica questo schema" + +#. 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 "Sostituzione parziale" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__position +msgid "Position" +msgstr "Posizione" + +#. 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 "Sostituisce" + +#. 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 "Oggetto (qui si può usare un segnaposto)" + +#. 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 "Modelli sostituzione oggetto" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template +msgid "Subject Template" +msgstr "Modello soggetto" + +#. 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 "Oggetto da sostituire" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__name +msgid "Template Name" +msgstr "Nome modello" + +#. 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 "" +"Il testo che verrà sostituito. Si possono usare segnaposto. Es.: {{ " +"object.company_id.name }}" + +#. 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 "" +"Se sostituire completamente, parzialmente, aggiungere all'inizio o alla fine " +"di altri modelli che si applicano a un dato contesto" diff --git a/mail_notification_custom_subject/i18n/mail_notification_custom_subject.pot b/mail_notification_custom_subject/i18n/mail_notification_custom_subject.pot new file mode 100644 index 000000000..8e89639df --- /dev/null +++ b/mail_notification_custom_subject/i18n/mail_notification_custom_subject.pot @@ -0,0 +1,136 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_notification_custom_subject +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__id +msgid "ID" +msgstr "" + +#. 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 "" + +#. 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 "" + +#. module: mail_notification_custom_subject +#: model:ir.model,name:mail_notification_custom_subject.model_mail_message_custom_subject +msgid "Mail Message Custom Subject" +msgstr "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. 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 "" + +#. module: mail_notification_custom_subject +#: model:ir.model.fields,field_description:mail_notification_custom_subject.field_mail_message_custom_subject__subject_template +msgid "Subject Template" +msgstr "" + +#. 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 +msgid "Template Name" +msgstr "" + +#. 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 "" diff --git a/mail_notification_custom_subject/models/__init__.py b/mail_notification_custom_subject/models/__init__.py new file mode 100644 index 000000000..3e5486eab --- /dev/null +++ b/mail_notification_custom_subject/models/__init__.py @@ -0,0 +1,2 @@ +from . import mail_thread +from . import mail_message_custom_subject diff --git a/mail_notification_custom_subject/models/mail_message_custom_subject.py b/mail_notification_custom_subject/models/mail_message_custom_subject.py new file mode 100644 index 000000000..79bf60fee --- /dev/null +++ b/mail_notification_custom_subject/models/mail_message_custom_subject.py @@ -0,0 +1,43 @@ +# Copyright 2020 Tecnativa - João Marques +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class MailMessageCustomSubject(models.Model): + _name = "mail.message.custom.subject" + _description = "Mail Message Custom Subject" + + name = fields.Char(string="Template Name") + model_id = fields.Many2one( + comodel_name="ir.model", + string="Model", + required=True, + help="Model where this template applies", + ondelete="cascade", + ) + subtype_ids = fields.Many2many( + comodel_name="mail.message.subtype", + string="Applied Subtypes", + required=True, + ) + subject_to_replace = fields.Char( + help="The text that will be replaced. You can use placeholders." + " E.g.: {{ object.company_id.name }}" + ) + subject_template = fields.Char( + required=True, + translate=True, + help="Subject (placeholders may be used here)", + ) + position = fields.Selection( + selection=[ + ("append_before", "Append Before"), + ("append_after", "Append After"), + ("replace", "Replace"), + ("inside_replace", "Partial Replacement"), + ], + default="replace", + help="Whether to replace completely, partially, append at beginning or append" + " at end to other templates that apply to a given context", + ) diff --git a/mail_notification_custom_subject/models/mail_thread.py b/mail_notification_custom_subject/models/mail_thread.py new file mode 100644 index 000000000..3ce2dce5f --- /dev/null +++ b/mail_notification_custom_subject/models/mail_thread.py @@ -0,0 +1,84 @@ +# Copyright 2020-2021 Tecnativa - João Marques +# Copyright 2021 Tecnativa - Pedro M. Baeza +# Copyright 2022 Moduon - Eduardo de Miguel +# Copyright 2025 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import logging + +from odoo import models + +_logger = logging.getLogger(__name__) + + +class MailThread(models.AbstractModel): + _inherit = "mail.thread" + + def message_post( + self, *args, subject=None, subtype_xmlid=None, subtype_id=False, **kwargs + ): + if subtype_xmlid: + subtype_id = self.env["ir.model.data"]._xmlid_to_res_id( + subtype_xmlid, + raise_if_not_found=False, + ) + if not subtype_id: + subtype_id = self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note") + if subtype_id: + domain = [ + ("model_id.model", "=", self._name), + ("subtype_ids", "=", subtype_id), + ] + if subject: + # If it already had a defined subject, we must respect it + domain += [("position", "!=", "replace")] + # Read templates with sudo: they are admin-managed configuration + # records, akin to mail.template. Portal and public users may + # trigger message_post (e.g. via portal controllers) and must be + # able to iterate the templates without hitting ACL errors. + custom_subjects = ( + self.env["mail.message.custom.subject"].sudo().search(domain) + ) + if not subject: + record_name = self.message_ids[:1].record_name + subject = f"Re: {record_name}" + for template in custom_subjects: + try: + rendered_subject_template = self.env[ + "mail.template" + ]._render_template( + template_src=template.subject_template, + model=self._name, + res_ids=[self.id], + )[self.id] + if template.position == "replace": + subject = rendered_subject_template + elif template.position == "append_before": + subject = rendered_subject_template + subject + elif template.position == "append_after": + subject += rendered_subject_template + elif template.position == "inside_replace": + rendered_subject_to_replace = self.env[ + "mail.template" + ]._render_template( + template_src=template.subject_to_replace, + model=self._name, + res_ids=[self.id], + )[self.id] + if rendered_subject_to_replace: + # To avoid empty string replacements + subject = subject.replace( + rendered_subject_to_replace, + rendered_subject_template, + ) + except Exception: + _logger.warning( + f"There is an error with {self.display_name} in the mail " + f"message custom subject {template.name}" + ) + return super().message_post( + *args, + subject=subject, + subtype_xmlid=subtype_xmlid, + subtype_id=subtype_id, + **kwargs, + ) diff --git a/mail_notification_custom_subject/pyproject.toml b/mail_notification_custom_subject/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/mail_notification_custom_subject/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_notification_custom_subject/readme/CONFIGURE.md b/mail_notification_custom_subject/readme/CONFIGURE.md new file mode 100644 index 000000000..8f025ed09 --- /dev/null +++ b/mail_notification_custom_subject/readme/CONFIGURE.md @@ -0,0 +1,17 @@ +- Activate access to **Technical Features** (debug mode). + +- Go to **Settings \> Technical \> Email \> Subject Replacement + Templates** + +- Create a new template. + + > - 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/18.0/applications/general/companies/email_template.html#dynamic-placeholders). + > - The field **Subject to replace** accepts + > [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 + > parcial replace existing content. diff --git a/mail_notification_custom_subject/readme/CONTRIBUTORS.md b/mail_notification_custom_subject/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5a26edcb0 --- /dev/null +++ b/mail_notification_custom_subject/readme/CONTRIBUTORS.md @@ -0,0 +1,15 @@ +- Tecnativa \<\> + + > - Pedro M. Baeza + > - João Marques + > - Carlos Roca + > - Víctor Martínez + +- Versada \<\> + - Naglis Jonaitis + +- Moduon \<\> + - Eduardo de Miguel + +- Codeforward \<\> + - Sander Lienaerts diff --git a/mail_notification_custom_subject/readme/DESCRIPTION.md b/mail_notification_custom_subject/readme/DESCRIPTION.md new file mode 100644 index 000000000..0f4b12c8b --- /dev/null +++ b/mail_notification_custom_subject/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows you to specify templates to override the subject on +the notification emails sent by Odoo diff --git a/mail_notification_custom_subject/readme/USAGE.md b/mail_notification_custom_subject/readme/USAGE.md new file mode 100644 index 000000000..7ff0b69cd --- /dev/null +++ b/mail_notification_custom_subject/readme/USAGE.md @@ -0,0 +1,5 @@ +To use this module, you need to: + +- Open the chatter in Odoo (e.g. Open an Invoice). +- Send a message. +- Observe the rendered Subject template. diff --git a/mail_notification_custom_subject/security/ir.model.access.csv b/mail_notification_custom_subject/security/ir.model.access.csv new file mode 100644 index 000000000..bc15034ae --- /dev/null +++ b/mail_notification_custom_subject/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_mail_notification_custom_subject_user,mail_notification_custom_object,model_mail_message_custom_subject,base.group_user,1,0,0,0 +access_mail_notification_custom_subject_admin,mail_notification_custom_object,model_mail_message_custom_subject,base.group_system,1,1,1,1 diff --git a/mail_notification_custom_subject/static/description/icon.png b/mail_notification_custom_subject/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mail_notification_custom_subject/static/description/icon.png differ diff --git a/mail_notification_custom_subject/static/description/index.html b/mail_notification_custom_subject/static/description/index.html new file mode 100644 index 000000000..5684a9eb5 --- /dev/null +++ b/mail_notification_custom_subject/static/description/index.html @@ -0,0 +1,492 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Mail Notification Custom Subject

+ +

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

+ +
+

Configuration

+
    +
  • Activate access to Technical Features (debug mode).

    +
  • +
  • Go to Settings > Technical > Email > Subject Replacement Templates

    +
  • +
  • Create a new template.

    +
    +
      +
    • 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.
    • +
    • The field Subject to replace accepts +expressions
    • +
    • The field Replace specifies if the template should replace +existing content or append to it.
    • +
    • The field Partial Replacement specifies if the template +should parcial replace existing content.
    • +
    +
    +
  • +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  • Open the chatter in Odoo (e.g. Open an Invoice).
  • +
  • Send a message.
  • +
  • Observe the rendered Subject template.
  • +
+
+
+

Bug Tracker

+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

yajo

+

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/__init__.py b/mail_notification_custom_subject/tests/__init__.py new file mode 100644 index 000000000..b0f2b2eff --- /dev/null +++ b/mail_notification_custom_subject/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_notification_custom_subject 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 new file mode 100644 index 000000000..d7598d691 --- /dev/null +++ b/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py @@ -0,0 +1,241 @@ +# Copyright 2020 Tecnativa - João Marques +# Copyright 2022-2025 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +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 + + +class TestMailNotificationCustomSubject(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_1, cls.partner_2 = cls.env["res.partner"].create( + [ + {"name": "Test partner 1", "email": "partner1@example.com"}, + {"name": "Test partner 2", "email": "partner2@example.com"}, + ] + ) + cls.admin = new_test_user(cls.env, "boss", "base.group_system") + new_test_user(cls.env, "worker_custom_subject") + new_test_user(cls.env, "portal_custom_subject", "base.group_portal") + cls.subject_model = cls.env["mail.message.custom.subject"].with_user(cls.admin) + + @users("worker_custom_subject") + def test_email_subject_template_overrides(self): + 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" + ) + # Get message and check subject + self.assertEqual(mail_message_1.subject, "Test partner 1 and something more") + + # Send message in partner 2 + mail_message_2 = self.partner_2.message_post( + body="Test", subtype_xmlid="mail.mt_comment" + ) + # Get message and check subject + self.assertEqual(mail_message_2.subject, "Test partner 2 and something more") + + # Explicit subject should not also overwritten + mail_message_3 = self.partner_2.message_post( + body="Test", subtype_xmlid="mail.mt_comment", subject="Test" + ) + # Get message and check subject + self.assertEqual(mail_message_3.subject, "Test") + + @users("worker_custom_subject") + def test_email_subject_template_inside_replace(self): + 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( + subject="COMPANY_LONG_NAME: Custom", + body="Test", + subtype_xmlid="mail.mt_comment", + ) + self.assertEqual(mail_message_1.subject, "CLN: Custom") + + @users("worker_custom_subject") + def test_email_subject_template_normal(self): + 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" + ) + # 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): + 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" + ) + # Get message and check subject + self.assertEqual( + mail_message_1.subject, "Test partner 1 and something different" + ) + 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" + ) + # Get message and check subject + self.assertEqual( + mail_message_2.subject, + "Test partner 1 and something different and yet something else", + ) + 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" + ) + # Get message and check subject + self.assertEqual( + mail_message_3.subject, + "Re: Test partner 1 and something different and yet something else", + ) + + @users("worker_custom_subject") + def test_email_subject_template_w_original(self): + 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", + subtype_xmlid="mail.mt_comment", + subject="Test", + ) + # 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.""" + 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 + 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( + body="Test", subtype_xmlid="mail.mt_comment", subject="Test partner 1" + ) + # Get message and check subject + # No exception should be raised but subject should remain as original. + self.assertEqual(mail_message_1.subject, "Test partner 1") + + @users("portal_custom_subject") + def test_email_subject_template_portal_user(self): + """Portal users triggering message_post via sudo (e.g. from a portal + controller) must render custom subject templates without hitting ACL + errors on mail.message.custom.subject — templates are admin-managed + configuration records and should be read with sudo.""" + self.subject_model.create( + { + "name": "Test portal template", + "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'}} - portal", + } + ) + portal_user = self.env.user + self.assertTrue(portal_user.has_group("base.group_portal")) + self.assertFalse(portal_user.has_group("base.group_user")) + # Mimic the portal controller pattern: the caller is the portal user, + # the record is sudo'd for message_post, and author_id is set to the + # portal user's partner. + partner = self.env["res.partner"].browse(self.partner_1.id) + mail_message = partner.sudo().message_post( + body="Test from portal", + subtype_xmlid="mail.mt_comment", + author_id=portal_user.partner_id.id, + ) + self.assertEqual(mail_message.author_id, portal_user.partner_id) + self.assertEqual(mail_message.subject, "Test partner 1 - portal") 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 new file mode 100644 index 000000000..a97f40a46 --- /dev/null +++ b/mail_notification_custom_subject/views/mail_notification_custom_subject_views.xml @@ -0,0 +1,60 @@ + + + + mail.message.custom.subject.form + mail.message.custom.subject + +
+ +
+
+ + + + + + + +
+
+
+
+ + mail.message.custom.subject.list + mail.message.custom.subject + + + + + + + + + + + Subject Replacement Templates + mail.message.custom.subject + form,list + + + +