mirror of https://github.com/OCA/social.git
[IMP] Add functionality to include original subject in quoted reply
This commit adds functionality to include the original subject of a message when composing a quoted reply. The `get_record_data` method in the `MailComposeMessage` model has been updated to check if there is a default subject and, if so, prepend "Re: " to it. This ensures that the new subject for the quoted reply includes a "Re:" prefix.pull/1456/head
parent
dbfd0aabfd
commit
65d2d5625b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
},
|
||||
}
|
||||
|
||||
);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -21,7 +21,9 @@ registerPatch({
|
|||
},
|
||||
sequence: {
|
||||
compute() {
|
||||
return this.messageActionListOwner === this.replyMessageAction ? 1 : this._super();
|
||||
return this.messageActionListOwner === this.replyMessageAction
|
||||
? 1
|
||||
: this._super();
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,7 +6,10 @@ 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();
|
||||
|
|
Loading…
Reference in New Issue