diff --git a/mail_quoted_reply/models/mail_compose_message.py b/mail_quoted_reply/models/mail_compose_message.py index 6bb2fa291..af5022635 100644 --- a/mail_quoted_reply/models/mail_compose_message.py +++ b/mail_quoted_reply/models/mail_compose_message.py @@ -1,6 +1,6 @@ from markupsafe import Markup -from odoo import api, models +from odoo import api, models, tools class MailComposeMessage(models.TransientModel): @@ -13,3 +13,11 @@ class MailComposeMessage(models.TransientModel): if "is_quoted_reply" in context.keys() and context["is_quoted_reply"]: self.body += Markup(context["quote_body"]) return + + @api.model + def get_record_data(self, values): + result = super().get_record_data(values) + subj = self._context.get("default_subject", False) + if subj: + result["subject"] = tools.ustr(subj) + return result diff --git a/mail_quoted_reply/models/mail_message.py b/mail_quoted_reply/models/mail_message.py index 38cc520b4..f416b2a48 100644 --- a/mail_quoted_reply/models/mail_message.py +++ b/mail_quoted_reply/models/mail_message.py @@ -5,7 +5,6 @@ from odoo import models class MailMessage(models.Model): - _inherit = "mail.message" def _prep_quoted_reply_body(self): @@ -45,4 +44,10 @@ class MailMessage(models.Model): "force_email": True, "default_partner_ids": self.partner_ids.ids, } + + # 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/static/src/models/message.esm.js b/mail_quoted_reply/static/src/models/message.esm.js index 0065f0be2..918b00100 100644 --- a/mail_quoted_reply/static/src/models/message.esm.js +++ b/mail_quoted_reply/static/src/models/message.esm.js @@ -1,6 +1,6 @@ /** @odoo-module **/ -import { registerPatch } from "@mail/model/model_core"; +import {registerPatch} from "@mail/model/model_core"; import rpc from "web.rpc"; @@ -8,7 +8,6 @@ registerPatch({ name: "Message", recordMethods: { - messageReply() { var self = this, msg_id = this.id; @@ -17,7 +16,8 @@ registerPatch({ method: "reply_message", args: [msg_id], }).then(function (result) { - return self.env.services.action.doAction(result, + return self.env.services.action.doAction( + result, { onClose: async () => { @@ -25,7 +25,6 @@ registerPatch({ self.env.bus.trigger("update-messages"); }, } - ); }); }, diff --git a/mail_quoted_reply/static/src/models/message_action.esm.js b/mail_quoted_reply/static/src/models/message_action.esm.js index 8d56ff8ef..f56c10e03 100644 --- a/mail_quoted_reply/static/src/models/message_action.esm.js +++ b/mail_quoted_reply/static/src/models/message_action.esm.js @@ -1,7 +1,7 @@ /** @odoo-module **/ -import { one } from "@mail/model/model_field"; -import { registerPatch } from "@mail/model/model_core"; +import {one} from "@mail/model/model_field"; +import {registerPatch} from "@mail/model/model_core"; registerPatch({ name: "MessageAction", @@ -21,7 +21,9 @@ registerPatch({ }, sequence: { compute() { - return this.messageActionListOwner === this.replyMessageAction ? 1 : this._super(); + return this.messageActionListOwner === this.replyMessageAction + ? 1 + : this._super(); }, }, }, diff --git a/mail_quoted_reply/static/src/models/message_action_list.esm.js b/mail_quoted_reply/static/src/models/message_action_list.esm.js index 5ddaee32d..ff8d68d87 100644 --- a/mail_quoted_reply/static/src/models/message_action_list.esm.js +++ b/mail_quoted_reply/static/src/models/message_action_list.esm.js @@ -1,8 +1,8 @@ /** @odoo-module **/ -import { clear } from "@mail/model/model_field_command"; -import { one } from "@mail/model/model_field"; -import { registerPatch } from "@mail/model/model_core"; +import {clear} from "@mail/model/model_field_command"; +import {one} from "@mail/model/model_field"; +import {registerPatch} from "@mail/model/model_core"; export const MESSAGE_TYPES = ["email", "comment"]; diff --git a/mail_quoted_reply/static/src/models/message_action_view.esm.js b/mail_quoted_reply/static/src/models/message_action_view.esm.js index 6441cdecc..5ce5b7b7c 100644 --- a/mail_quoted_reply/static/src/models/message_action_view.esm.js +++ b/mail_quoted_reply/static/src/models/message_action_view.esm.js @@ -1,12 +1,15 @@ /** @odoo-module **/ -import { registerPatch } from "@mail/model/model_core"; +import {registerPatch} from "@mail/model/model_core"; registerPatch({ name: "MessageActionView", recordMethods: { onClick(ev) { - if (this.messageAction.messageActionListOwner === this.messageAction.replyMessageAction) { + if ( + this.messageAction.messageActionListOwner === + this.messageAction.replyMessageAction + ) { this.messageAction.messageActionListOwner.message.messageReply(); } else { this._super(ev); @@ -17,7 +20,10 @@ registerPatch({ classNames: { compute() { let classNames = this._super() || ""; - if (this.messageAction.messageActionListOwner === this.messageAction.replyMessageAction) { + if ( + this.messageAction.messageActionListOwner === + this.messageAction.replyMessageAction + ) { classNames += " fa fa-lg fa-reply"; } return classNames; @@ -25,7 +31,10 @@ registerPatch({ }, title: { compute() { - if (this.messageAction.messageActionListOwner === this.messageAction.replyMessageAction) { + if ( + this.messageAction.messageActionListOwner === + this.messageAction.replyMessageAction + ) { return this.env._t("Reply"); } return this._super();