diff --git a/mail_quoted_reply/README.rst b/mail_quoted_reply/README.rst new file mode 100644 index 0000000000..9816a205a8 --- /dev/null +++ b/mail_quoted_reply/README.rst @@ -0,0 +1,94 @@ +================== +Mail Message Reply +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:96ee412b2c8c5a8d16223e5cfde5f442bdcbd230882516934e376d7fe0da8c08 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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_quoted_reply + :alt: OCA/social +.. |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_quoted_reply + :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 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon allow to reply on messages from odoo directly. It is useful +when replying to a message from a customer. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +On the messages from threads, a reply button is shown. Once it has been +pressed, a composer with the reply is shown. + +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 +------- + +* Creu Blanca + +Contributors +------------ + +- Enric Tobella +- Lois Rilo +- Giuseppe Borruso +- Laurence Labusch +- Dani Forga +- Tris Doan + +Other credits +------------- + +The migration from 16.0 to 17.0 of this module were financially +supported by Camptocamp. + +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. + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_quoted_reply/__init__.py b/mail_quoted_reply/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/mail_quoted_reply/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_quoted_reply/__manifest__.py b/mail_quoted_reply/__manifest__.py new file mode 100644 index 0000000000..c55c42470e --- /dev/null +++ b/mail_quoted_reply/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Mail Message Reply", + "summary": """ + Make a reply using a message""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "depends": ["mail"], + "data": [], + "assets": { + "web.assets_backend": [ + "/mail_quoted_reply/static/src/*.js", + ], + }, +} diff --git a/mail_quoted_reply/i18n/ca.po b/mail_quoted_reply/i18n/ca.po new file mode 100644 index 0000000000..186f4937ac --- /dev/null +++ b/mail_quoted_reply/i18n/ca.po @@ -0,0 +1,96 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_quoted_reply +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-07-04 15:05+0000\n" +"Last-Translator: jabelchi \n" +"Language-Team: none\n" +"Language: ca\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 4.3.2\n" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Date" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistent de redacció d'emails" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "From" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "Missatge" + +#. module: mail_quoted_reply +#. odoo-javascript +#: code:addons/mail_quoted_reply/static/src/models/message_action_view.esm.js:0 +#, python-format +msgid "Reply" +msgstr "Respon" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Subject" +msgstr "" + +#~ msgid "" +#~ "\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ " From: ${object.email_from}
\n" +#~ " Date: ${object.date}
\n" +#~ " Subject: ${object.subject}
\n" +#~ " ${object.body | safe}\n" +#~ "
\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ " From: ${object.email_from}
\n" +#~ " Date: ${object.date}
\n" +#~ " Subject: ${object.subject}
\n" +#~ " ${object.body | safe}\n" +#~ "
\n" +#~ " " + +#~ msgid "Display Name" +#~ msgstr "Nom a mostrar" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Darrera modificació el" + +#~ msgid "Re: ${object.subject}" +#~ msgstr "Re: ${object.subject}" diff --git a/mail_quoted_reply/i18n/es.po b/mail_quoted_reply/i18n/es.po new file mode 100644 index 0000000000..758904bb99 --- /dev/null +++ b/mail_quoted_reply/i18n/es.po @@ -0,0 +1,96 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_quoted_reply +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-10 19:33+0000\n" +"Last-Translator: Ivorra78 \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 4.17\n" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Date" +msgstr "Fecha" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Asistente composición Correo Electrónico" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "From" +msgstr "Desde" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "Mensaje" + +#. module: mail_quoted_reply +#. odoo-javascript +#: code:addons/mail_quoted_reply/static/src/models/message_action_view.esm.js:0 +#, python-format +msgid "Reply" +msgstr "Responder" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Subject" +msgstr "Asunto" + +#~ msgid "" +#~ "\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ " From: ${object.email_from}
\n" +#~ " Date: ${object.date}
\n" +#~ " Subject: ${object.subject}
\n" +#~ " ${object.body | safe}\n" +#~ "
\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ "
\n" +#~ " From: ${object.email_from}
\n" +#~ " Date: ${object.date}
\n" +#~ " Subject: ${object.subject}
\n" +#~ " ${object.body | safe}\n" +#~ "
\n" +#~ " " + +#~ msgid "Display Name" +#~ msgstr "Nombre mostrado" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última modificación el" + +#~ msgid "Re: ${object.subject}" +#~ msgstr "Re: ${object.subject}" diff --git a/mail_quoted_reply/i18n/it.po b/mail_quoted_reply/i18n/it.po new file mode 100644 index 0000000000..f54b9f1fe6 --- /dev/null +++ b/mail_quoted_reply/i18n/it.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_quoted_reply +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-11 08: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 4.17\n" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Date" +msgstr "Data" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Procedura guidata creazione e-mail" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "From" +msgstr "Dal" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "Messaggio" + +#. module: mail_quoted_reply +#. odoo-javascript +#: code:addons/mail_quoted_reply/static/src/models/message_action_view.esm.js:0 +#, python-format +msgid "Reply" +msgstr "Rispondi" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Subject" +msgstr "Soggetto" diff --git a/mail_quoted_reply/i18n/mail_quoted_reply.pot b/mail_quoted_reply/i18n/mail_quoted_reply.pot new file mode 100644 index 0000000000..991674b227 --- /dev/null +++ b/mail_quoted_reply/i18n/mail_quoted_reply.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_quoted_reply +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Date" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "From" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "" + +#. module: mail_quoted_reply +#. odoo-javascript +#: code:addons/mail_quoted_reply/static/src/models/message_action_view.esm.js:0 +#, python-format +msgid "Reply" +msgstr "" + +#. module: mail_quoted_reply +#. odoo-python +#: code:addons/mail_quoted_reply/models/mail_message.py:0 +#, python-format +msgid "Subject" +msgstr "" diff --git a/mail_quoted_reply/models/__init__.py b/mail_quoted_reply/models/__init__.py new file mode 100644 index 0000000000..a5fceda6ab --- /dev/null +++ b/mail_quoted_reply/models/__init__.py @@ -0,0 +1,2 @@ +from . import mail_message +from . import mail_compose_message diff --git a/mail_quoted_reply/models/mail_compose_message.py b/mail_quoted_reply/models/mail_compose_message.py new file mode 100644 index 0000000000..3ff708b60a --- /dev/null +++ b/mail_quoted_reply/models/mail_compose_message.py @@ -0,0 +1,38 @@ +from markupsafe import Markup + +from odoo import api, models, tools + + +class MailComposeMessage(models.TransientModel): + _inherit = "mail.compose.message" + + @api.depends("composition_mode", "model", "res_domain", "res_ids", "template_id") + @api.depends_context("is_quoted_reply") + def _compute_body(self): + res = super()._compute_body() + for composer in self: + context = composer._context + if context.get("is_quoted_reply"): + if composer.body: + composer.body += Markup(context["quote_body"]) + else: + composer.body = Markup(context["quote_body"]) + return res + + @api.depends( + "composition_mode", + "model", + "parent_id", + "record_name", + "res_domain", + "res_ids", + "template_id", + ) + @api.depends_context("default_subject") + def _compute_subject(self): + res = super()._compute_subject() + for composer in self: + subj = composer._context.get("default_subject", False) + if subj: + composer.subject = tools.ustr(subj) + return res diff --git a/mail_quoted_reply/models/mail_message.py b/mail_quoted_reply/models/mail_message.py new file mode 100644 index 0000000000..be5905d194 --- /dev/null +++ b/mail_quoted_reply/models/mail_message.py @@ -0,0 +1,69 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models +from odoo.tools import format_datetime, html_sanitize + + +class MailMessage(models.Model): + _inherit = "mail.message" + + def _get_sanitized_body(self): + self.ensure_one() + return html_sanitize(self.body) + + def _prep_quoted_reply_body(self): + return """ +
+

+
+

+ {signature} +
+
+
+ {str_from}: {email_from}
+ {str_date}: {date}
+ {str_subject}: {subject}
+ {body} +
+
+ """.format( + email_from=self.email_from, + date=format_datetime(self.env, self.date), + subject=self.subject, + body=self._get_sanitized_body(), + signature=self.env.user.signature, + str_date=_("Date"), + str_subject=_("Subject"), + str_from=_("From"), + ) + + def _default_reply_partner(self): + return self.env["res.partner"].find_or_create(self.email_from).ids + + def reply_message(self): + action = self.env["ir.actions.actions"]._for_xml_id( + "mail.action_email_compose_message_wizard" + ) + action["context"] = { + "default_model": self.model, + "default_res_ids": [self.res_id], + "default_composition_mode": "comment", + "quote_body": self._prep_quoted_reply_body(), + "default_is_log": False, + "is_log": False, + "is_quoted_reply": True, + "default_notify": True, + "force_email": True, + "default_partner_ids": self._default_reply_partner(), + } + + # If the original message had a subject, we use it as a base for the + # new subject, adding a "Re:" at the beginning. + if self.subject: + action["context"]["default_subject"] = f"Re: {self.subject}" + + return action diff --git a/mail_quoted_reply/pyproject.toml b/mail_quoted_reply/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/mail_quoted_reply/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_quoted_reply/readme/CONTRIBUTORS.md b/mail_quoted_reply/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..768cb1925c --- /dev/null +++ b/mail_quoted_reply/readme/CONTRIBUTORS.md @@ -0,0 +1,7 @@ +- Enric Tobella +- Lois Rilo \<\> +- Giuseppe Borruso \<\> +- Laurence Labusch \<\> +- Dani Forga +- Tris Doan \<\> +- Akim Juillerat \<> diff --git a/mail_quoted_reply/readme/CREDITS.md b/mail_quoted_reply/readme/CREDITS.md new file mode 100644 index 0000000000..2807d293d2 --- /dev/null +++ b/mail_quoted_reply/readme/CREDITS.md @@ -0,0 +1 @@ +The migration from 16.0 to 17.0 of this module were financially supported by Camptocamp. diff --git a/mail_quoted_reply/readme/DESCRIPTION.md b/mail_quoted_reply/readme/DESCRIPTION.md new file mode 100644 index 0000000000..32b30b51dc --- /dev/null +++ b/mail_quoted_reply/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This addon allow to reply on messages from odoo directly. It is useful +when replying to a message from a customer. diff --git a/mail_quoted_reply/readme/USAGE.md b/mail_quoted_reply/readme/USAGE.md new file mode 100644 index 0000000000..e5ce6880c2 --- /dev/null +++ b/mail_quoted_reply/readme/USAGE.md @@ -0,0 +1,2 @@ +On the messages from threads, a reply button is shown. Once it has been +pressed, a composer with the reply is shown. diff --git a/mail_quoted_reply/static/description/icon.png b/mail_quoted_reply/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/mail_quoted_reply/static/description/icon.png differ diff --git a/mail_quoted_reply/static/description/index.html b/mail_quoted_reply/static/description/index.html new file mode 100644 index 0000000000..76da14318a --- /dev/null +++ b/mail_quoted_reply/static/description/index.html @@ -0,0 +1,441 @@ + + + + + +Mail Message Reply + + + +
+

Mail Message Reply

+ + +

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

+

This addon allow to reply on messages from odoo directly. It is useful +when replying to a message from a customer.

+

Table of contents

+ +
+

Usage

+

On the messages from threads, a reply button is shown. Once it has been +pressed, a composer with the reply is shown.

+
+
+

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

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration from 16.0 to 17.0 of this module were financially +supported by Camptocamp.

+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/mail_quoted_reply/static/src/message_actions.esm.js b/mail_quoted_reply/static/src/message_actions.esm.js new file mode 100644 index 0000000000..4790bc4efe --- /dev/null +++ b/mail_quoted_reply/static/src/message_actions.esm.js @@ -0,0 +1,11 @@ +/* @odoo-module */ + +import {messageActionsRegistry} from "@mail/core/common/message_actions"; + +messageActionsRegistry.add("reply", { + icon: "fa-reply", + title: "Reply", + onClick: (component) => + component.messageService.messageReply(component.props.message), + condition: (component) => component.canReply, +}); diff --git a/mail_quoted_reply/static/src/message_patch.esm.js b/mail_quoted_reply/static/src/message_patch.esm.js new file mode 100644 index 0000000000..3479c6a90a --- /dev/null +++ b/mail_quoted_reply/static/src/message_patch.esm.js @@ -0,0 +1,20 @@ +/* @odoo-module */ + +import {Message} from "@mail/core/common/message"; +import {patch} from "@web/core/utils/patch"; + +export const MESSAGE_TYPES = ["email", "comment"]; + +export const isMessageTypeValid = (type) => { + return MESSAGE_TYPES.includes(type); +}; + +patch(Message, { + components: {...Message.components}, +}); + +patch(Message.prototype, { + get canReply() { + return Boolean(this.message.res_id && isMessageTypeValid(this.message.type)); + }, +}); diff --git a/mail_quoted_reply/static/src/message_service.esm.js b/mail_quoted_reply/static/src/message_service.esm.js new file mode 100644 index 0000000000..d690148ded --- /dev/null +++ b/mail_quoted_reply/static/src/message_service.esm.js @@ -0,0 +1,29 @@ +/* @odoo-module */ + +import {patch} from "@web/core/utils/patch"; +import {MessageService} from "@mail/core/common/message_service"; +import {useService} from "@web/core/utils/hooks"; + +patch(MessageService.prototype, { + setup() { + super.setup(); + this.threadService = useService("mail.thread"); + }, + + async messageReply(message) { + var self = this; + const thread = message.originThread; + await this.orm + .call("mail.message", "reply_message", [message.id]) + .then(function (result) { + return self.env.services.action.doAction(result, { + onClose: async () => { + await self.env.services["mail.thread"].fetchData(thread, [ + "messages", + ]); + self.env.bus.trigger("update-messages"); + }, + }); + }); + }, +}); diff --git a/mail_quoted_reply/tests/__init__.py b/mail_quoted_reply/tests/__init__.py new file mode 100644 index 0000000000..5543674dcd --- /dev/null +++ b/mail_quoted_reply/tests/__init__.py @@ -0,0 +1 @@ +from . import test_reply diff --git a/mail_quoted_reply/tests/test_reply.py b/mail_quoted_reply/tests/test_reply.py new file mode 100644 index 0000000000..ef1f7c220f --- /dev/null +++ b/mail_quoted_reply/tests/test_reply.py @@ -0,0 +1,46 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import re + +from odoo.tests import TransactionCase + + +class TestMessageReply(TransactionCase): + def test_reply(self): + partner = self.env["res.partner"].create({"name": "demo partner"}) + self.assertFalse( + partner.message_ids.filtered(lambda r: r.message_type != "notification") + ) + # pylint: disable=C8107 + message = partner.message_post( + body="demo message", + message_type="email", + partner_ids=self.env.ref("base.partner_demo").ids, + ) + partner.invalidate_recordset() + self.assertIn( + message, + partner.message_ids.filtered(lambda r: r.message_type != "notification"), + ) + self.assertFalse( + partner.message_ids.filtered( + lambda r: r.message_type != "notification" and r != message + ) + ) + action = message.reply_message() + wizard = ( + self.env[action["res_model"]].with_context(**action["context"]).create({}) + ) + self.assertTrue(wizard.partner_ids) + self.assertEqual(message.email_from, wizard.partner_ids.email_formatted) + # the onchange in the composer isn't triggered in tests, so we check for the + # correct quote in the context + email_quote = re.search("

.*?

", wizard._context["quote_body"]).group() + self.assertEqual("

demo message

", email_quote) + wizard.action_send_mail() + new_message = partner.message_ids.filtered( + lambda r: r.message_type != "notification" and r != message + ) + self.assertTrue(new_message) + self.assertEqual(1, len(new_message))