diff --git a/mail_quoted_reply/README.rst b/mail_quoted_reply/README.rst new file mode 100644 index 0000000..890dde8 --- /dev/null +++ b/mail_quoted_reply/README.rst @@ -0,0 +1,81 @@ +================== +Mail Message Reply +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.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-14-0/social-14-0-mail_quoted_reply + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/14.0 + :alt: Try me on Runbot + +|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 smashing 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 + +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 0000000..0650744 --- /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 0000000..e5a5134 --- /dev/null +++ b/mail_quoted_reply/__manifest__.py @@ -0,0 +1,23 @@ +# 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": "15.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_qweb": [ + "/mail_quoted_reply/static/src/xml/mail_message_reply.xml", + ], + "web.assets_backend": [ + "/mail_quoted_reply/static/src/models/mail_message_reply.esm.js", + "/mail_quoted_reply/static/src/components/mail_message_reply.esm.js", + ], + }, +} diff --git a/mail_quoted_reply/i18n/ca.po b/mail_quoted_reply/i18n/ca.po new file mode 100644 index 0000000..baf162f --- /dev/null +++ b/mail_quoted_reply/i18n/ca.po @@ -0,0 +1,86 @@ +# 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 +#: model:mail.template,body_html:mail_quoted_reply.reply_template +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" +" " + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__display_name +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__display_name +msgid "Display Name" +msgstr "Nom a mostrar" + +#. 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 +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__id +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__id +msgid "ID" +msgstr "ID" + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message____last_update +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message____last_update +msgid "Last Modified on" +msgstr "Darrera modificació el" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "Missatge" + +#. module: mail_quoted_reply +#: model:mail.template,subject:mail_quoted_reply.reply_template +msgid "Re: ${object.subject}" +msgstr "Re: ${object.subject}" + +#. module: mail_quoted_reply +#. openerp-web +#: code:addons/mail_quoted_reply/static/src/xml/mail_message_reply.xml:0 +#, python-format +msgid "Reply" +msgstr "Respon" diff --git a/mail_quoted_reply/i18n/es.po b/mail_quoted_reply/i18n/es.po new file mode 100644 index 0000000..db0ec0c --- /dev/null +++ b/mail_quoted_reply/i18n/es.po @@ -0,0 +1,86 @@ +# 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: 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.3.2\n" + +#. module: mail_quoted_reply +#: model:mail.template,body_html:mail_quoted_reply.reply_template +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" +" " + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__display_name +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. 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 +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__id +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__id +msgid "ID" +msgstr "ID" + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message____last_update +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "Mensaje" + +#. module: mail_quoted_reply +#: model:mail.template,subject:mail_quoted_reply.reply_template +msgid "Re: ${object.subject}" +msgstr "Re: ${object.subject}" + +#. module: mail_quoted_reply +#. openerp-web +#: code:addons/mail_quoted_reply/static/src/xml/mail_message_reply.xml:0 +#, python-format +msgid "Reply" +msgstr "Responder" 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 0000000..e7b132b --- /dev/null +++ b/mail_quoted_reply/i18n/mail_quoted_reply.pot @@ -0,0 +1,70 @@ +# 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" +"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 +#: model:mail.template,body_html:mail_quoted_reply.reply_template +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 "" + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__display_name +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__display_name +msgid "Display Name" +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 +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message__id +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message__id +msgid "ID" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_compose_message____last_update +#: model:ir.model.fields,field_description:mail_quoted_reply.field_mail_message____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mail_quoted_reply +#: model:ir.model,name:mail_quoted_reply.model_mail_message +msgid "Message" +msgstr "" + +#. module: mail_quoted_reply +#: model:mail.template,subject:mail_quoted_reply.reply_template +msgid "Re: ${object.subject}" +msgstr "" + +#. module: mail_quoted_reply +#. openerp-web +#: code:addons/mail_quoted_reply/static/src/xml/mail_message_reply.xml:0 +#, python-format +msgid "Reply" +msgstr "" diff --git a/mail_quoted_reply/models/__init__.py b/mail_quoted_reply/models/__init__.py new file mode 100644 index 0000000..a5fceda --- /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 0000000..6bb2fa2 --- /dev/null +++ b/mail_quoted_reply/models/mail_compose_message.py @@ -0,0 +1,15 @@ +from markupsafe import Markup + +from odoo import api, models + + +class MailComposeMessage(models.TransientModel): + _inherit = "mail.compose.message" + + @api.onchange("template_id") + def _onchange_template_id_wrapper(self): + super()._onchange_template_id_wrapper() + context = self._context + if "is_quoted_reply" in context.keys() and context["is_quoted_reply"]: + self.body += Markup(context["quote_body"]) + return diff --git a/mail_quoted_reply/models/mail_message.py b/mail_quoted_reply/models/mail_message.py new file mode 100644 index 0000000..242a414 --- /dev/null +++ b/mail_quoted_reply/models/mail_message.py @@ -0,0 +1,48 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MailMessage(models.Model): + + _inherit = "mail.message" + + def _prep_quoted_reply_body(self): + return """ +
+
+
+
+
+
+ From: {email_from}
+ Date: {date}
+ Subject: {subject}
+ {body} +
+ """.format( + email_from=self.email_from, + date=self.date, + subject=self.subject, + body=self.body, + ) + + 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_id": 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": [(6, 0, self.partner_ids.ids)], + } + return action diff --git a/mail_quoted_reply/readme/CONTRIBUTORS.rst b/mail_quoted_reply/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..a1b2570 --- /dev/null +++ b/mail_quoted_reply/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Enric Tobella +* Lois Rilo diff --git a/mail_quoted_reply/readme/DESCRIPTION.rst b/mail_quoted_reply/readme/DESCRIPTION.rst new file mode 100644 index 0000000..fbaa89b --- /dev/null +++ b/mail_quoted_reply/readme/DESCRIPTION.rst @@ -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.rst b/mail_quoted_reply/readme/USAGE.rst new file mode 100644 index 0000000..2a57635 --- /dev/null +++ b/mail_quoted_reply/readme/USAGE.rst @@ -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 0000000..3a0328b 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 0000000..a4bf75e --- /dev/null +++ b/mail_quoted_reply/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Mail Message Reply + + + +
+

Mail Message Reply

+ + +

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

+

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 smashing 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

+ +
+
+

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/components/mail_message_reply.esm.js b/mail_quoted_reply/static/src/components/mail_message_reply.esm.js new file mode 100644 index 0000000..81a7fc2 --- /dev/null +++ b/mail_quoted_reply/static/src/components/mail_message_reply.esm.js @@ -0,0 +1,38 @@ +/** @odoo-module **/ + +import {MessageActionList} from "@mail/components/message_action_list/message_action_list"; +import {patch} from "web.utils"; +import {qweb} from "web.core"; + +const {onMounted} = owl.hooks; + +patch( + MessageActionList.prototype, + "mail_quoted_reply/static/src/components/mail_message_reply.js", + { + xmlDependencies: (MessageActionList.prototype.xmlDependencies || []).concat([ + "/mail_quoted_reply/static/src/xml/mail_message_reply.xml", + ]), + + setup() { + this._super(); + onMounted(() => { + var actionLists = document.querySelectorAll(".o_MessageActionList"); + var MessageQuotedReplyIcon = $( + qweb.render("MessageQuotedReplyButton", this) + )[0]; + if (typeof MessageQuotedReplyIcon !== "undefined") { + MessageQuotedReplyIcon.addEventListener( + "click", + this.messaging.models["mail.message_action_list"].get( + this.props.messageActionListLocalId + ).onClickMailMessageReply + ); + } + actionLists.forEach((actionList) => { + actionList.append(MessageQuotedReplyIcon); + }); + }); + }, + } +); diff --git a/mail_quoted_reply/static/src/models/mail_message_reply.esm.js b/mail_quoted_reply/static/src/models/mail_message_reply.esm.js new file mode 100644 index 0000000..4017d76 --- /dev/null +++ b/mail_quoted_reply/static/src/models/mail_message_reply.esm.js @@ -0,0 +1,38 @@ +/** @odoo-module **/ + +import {registerInstancePatchModel} from "@mail/model/model_core"; +import rpc from "web.rpc"; + +registerInstancePatchModel( + "mail.message_action_list", + "mail_quoted_reply/static/src/models/mail_message_reply.js", + { + _created() { + this._super(); + this.onClickMailMessageReply = this.onClickMailMessageReply.bind(this); + }, + + /** + * @private + * @param {MouseEvent} ev + */ + onClickMailMessageReply() { + var self = this, + msg_id = this.message.id; + rpc.query({ + model: "mail.message", + method: "reply_message", + args: [msg_id], + }).then(function (result) { + self.env.bus.trigger("do-action", { + action: result, + options: { + on_close: () => { + self.message.originThread.refresh(); + }, + }, + }); + }); + }, + } +); diff --git a/mail_quoted_reply/static/src/xml/mail_message_reply.xml b/mail_quoted_reply/static/src/xml/mail_message_reply.xml new file mode 100644 index 0000000..9f91cd6 --- /dev/null +++ b/mail_quoted_reply/static/src/xml/mail_message_reply.xml @@ -0,0 +1,10 @@ + + diff --git a/mail_quoted_reply/tests/__init__.py b/mail_quoted_reply/tests/__init__.py new file mode 100644 index 0000000..5543674 --- /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 0000000..392e2fa --- /dev/null +++ b/mail_quoted_reply/tests/test_reply.py @@ -0,0 +1,40 @@ +# 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.refresh() + 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({}) + ) + # 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)) diff --git a/setup/mail_quoted_reply/odoo/addons/mail_quoted_reply b/setup/mail_quoted_reply/odoo/addons/mail_quoted_reply new file mode 120000 index 0000000..4df09f3 --- /dev/null +++ b/setup/mail_quoted_reply/odoo/addons/mail_quoted_reply @@ -0,0 +1 @@ +../../../../mail_quoted_reply \ No newline at end of file diff --git a/setup/mail_quoted_reply/setup.py b/setup/mail_quoted_reply/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/mail_quoted_reply/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)