diff --git a/mail_quoted_reply/__init__.py b/mail_quoted_reply/__init__.py
index aee8895..0650744 100644
--- a/mail_quoted_reply/__init__.py
+++ b/mail_quoted_reply/__init__.py
@@ -1,2 +1 @@
from . import models
-from . import wizards
diff --git a/mail_quoted_reply/__manifest__.py b/mail_quoted_reply/__manifest__.py
index b001a9a..e5a5134 100644
--- a/mail_quoted_reply/__manifest__.py
+++ b/mail_quoted_reply/__manifest__.py
@@ -5,14 +5,19 @@
"name": "Mail Message Reply",
"summary": """
Make a reply using a message""",
- "version": "14.0.1.0.0",
+ "version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"depends": ["mail"],
- "qweb": ["static/src/xml/mail_message_reply.xml"],
- "data": [
- "templates/assets.xml",
- "data/reply_template.xml",
- ],
+ "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/data/reply_template.xml b/mail_quoted_reply/data/reply_template.xml
deleted file mode 100644
index b015098..0000000
--- a/mail_quoted_reply/data/reply_template.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- From: ${object.email_from}
- ]]>
- Date: ${object.date}
- Subject: ${object.subject}
- ${object.body | safe}
-
+ From: {email_from}+ """.format( + email_from=self.email_from, + date=self.date, + subject=self.subject, + body=self.body, + ) + def reply_message(self): action = self.env.ref("mail.action_email_compose_message_wizard").read()[0] action["context"] = { - "default_model": self._name, - "default_res_id": self.id, - "default_template_id": self.env.ref("mail_quoted_reply.reply_template").id, + "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, - "reassign_to_parent": True, "default_partner_ids": [(6, 0, self.partner_ids.ids)], } return action 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/components/mail_message_reply.js b/mail_quoted_reply/static/src/components/mail_message_reply.js deleted file mode 100644 index da29add..0000000 --- a/mail_quoted_reply/static/src/components/mail_message_reply.js +++ /dev/null @@ -1,20 +0,0 @@ -odoo.define("mail_quoted_reply/static/src/components/mail_message_reply.js", function ( - require -) { - "use strict"; - - const components = { - Message: require("mail/static/src/components/message/message.js"), - }; - const {patch} = require("web.utils"); - - patch( - components.Message, - "mail_quoted_reply/static/src/models/mail_message_reply.js", - { - _onClickMailMessageReply() { - this.message._onClickMailMessageReply(); - }, - } - ); -}); 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/models/mail_message_reply.js b/mail_quoted_reply/static/src/models/mail_message_reply.js deleted file mode 100644 index 005c818..0000000 --- a/mail_quoted_reply/static/src/models/mail_message_reply.js +++ /dev/null @@ -1,34 +0,0 @@ -odoo.define("mail_quoted_reply/static/src/models/mail_message_reply.js", function ( - require -) { - "use strict"; - - const {registerInstancePatchModel} = require("mail/static/src/model/model_core.js"); - - registerInstancePatchModel( - "mail.message", - "mail_quoted_reply/static/src/models/mail_message_reply.js", - { - _onClickMailMessageReply: function () { - var self = this, - msg_id = this.id; - this.env.services - .rpc({ - model: "mail.message", - method: "reply_message", - args: [msg_id], - }) - .then(function (result) { - self.env.bus.trigger("do-action", { - action: result, - options: { - on_close: () => { - self.originThread.refresh(); - }, - }, - }); - }); - }, - } - ); -}); diff --git a/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss b/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss deleted file mode 100644 index 0d3acbe..0000000 --- a/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss +++ /dev/null @@ -1,21 +0,0 @@ -.o_thread_mail_message_reply { - cursor: pointer; - color: gray("400"); - &:not(.o-mobile) { - &:hover { - filter: brightness(0.8); - } - } - - &.o-mobile { - filter: brightness(0.8); - - &:hover { - filter: brightness(0.75); - } - } - - &.o-message-selected { - color: gray("500"); - } -} diff --git a/mail_quoted_reply/static/src/xml/mail_message_reply.xml b/mail_quoted_reply/static/src/xml/mail_message_reply.xml index ccf41ab..9f91cd6 100644 --- a/mail_quoted_reply/static/src/xml/mail_message_reply.xml +++ b/mail_quoted_reply/static/src/xml/mail_message_reply.xml @@ -1,19 +1,10 @@ - -
+ Date: {date}
+ Subject: {subject}
+ {body} +
.*?
", 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 diff --git a/mail_quoted_reply/wizards/__init__.py b/mail_quoted_reply/wizards/__init__.py deleted file mode 100644 index 7096b0c..0000000 --- a/mail_quoted_reply/wizards/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import mail_compose_message_reply diff --git a/mail_quoted_reply/wizards/mail_compose_message_reply.py b/mail_quoted_reply/wizards/mail_compose_message_reply.py deleted file mode 100644 index 7e94637..0000000 --- a/mail_quoted_reply/wizards/mail_compose_message_reply.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 Creu Blanca -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class MailComposeMessageReply(models.TransientModel): - - _inherit = "mail.compose.message" - - def send_mail(self, auto_commit=False): - if self.env.context.get("reassign_to_parent"): - for record in self: - if record.model == "mail.message": - parent = self.env[record.model].browse(record.res_id) - record.model = parent.model - record.res_id = parent.res_id - record.parent_id = parent - return super().send_mail(auto_commit=auto_commit)