mirror of https://github.com/OCA/social.git
[MIG] mail_quoted_reply: Migration to 17.0
parent
731fd76a64
commit
11e8d5038c
|
@ -68,6 +68,13 @@ Contributors
|
|||
- Giuseppe Borruso <gborruso@dinamicheaziendali.it>
|
||||
- Laurence Labusch <lala@labiso.de>
|
||||
- Dani Forga
|
||||
- Tris Doan <tridm@trobz.com>
|
||||
|
||||
Other credits
|
||||
-------------
|
||||
|
||||
The migration from 16.0 to 17.0 of this module were financially
|
||||
supported by Camptocamp.
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"name": "Mail Message Reply",
|
||||
"summary": """
|
||||
Make a reply using a message""",
|
||||
"version": "16.0.1.0.2",
|
||||
"version": "17.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/social",
|
||||
|
@ -13,7 +13,7 @@
|
|||
"data": [],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"/mail_quoted_reply/static/src/models/*.js",
|
||||
"/mail_quoted_reply/static/src/*.js",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -6,18 +6,28 @@ from odoo import api, models, tools
|
|||
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
|
||||
@api.depends("composition_mode", "model", "res_domain", "res_ids", "template_id")
|
||||
def _compute_body(self):
|
||||
res = super()._compute_body()
|
||||
for composer in self:
|
||||
context = composer._context
|
||||
if context.get("is_quoted_reply"):
|
||||
composer.body = Markup(context["quote_body"])
|
||||
return res
|
||||
|
||||
@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
|
||||
@api.depends(
|
||||
"composition_mode",
|
||||
"model",
|
||||
"parent_id",
|
||||
"record_name",
|
||||
"res_domain",
|
||||
"res_ids",
|
||||
"template_id",
|
||||
)
|
||||
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
|
||||
|
|
|
@ -17,8 +17,9 @@ class MailMessage(models.Model):
|
|||
{signature}
|
||||
<br />
|
||||
<br />
|
||||
<blockquote style="padding-right:0px; padding-left:5px; border-left-color: #000;
|
||||
margin-left:5px; margin-right:0px;border-left-width: 2px; border-left-style:solid">
|
||||
<blockquote style="padding-right:0px; padding-left:5px;
|
||||
border-left-color: #000; margin-left:5px; margin-right:0px;
|
||||
border-left-width: 2px; border-left-style:solid">
|
||||
{str_from}: {email_from}<br/>
|
||||
{str_date}: {date}<br/>
|
||||
{str_subject}: {subject}<br/>
|
||||
|
@ -45,7 +46,7 @@ class MailMessage(models.Model):
|
|||
)
|
||||
action["context"] = {
|
||||
"default_model": self.model,
|
||||
"default_res_id": self.res_id,
|
||||
"default_res_ids": [self.res_id],
|
||||
"default_composition_mode": "comment",
|
||||
"quote_body": self._prep_quoted_reply_body(),
|
||||
"default_is_log": False,
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
- Giuseppe Borruso \<<gborruso@dinamicheaziendali.it>\>
|
||||
- Laurence Labusch \<<lala@labiso.de>\>
|
||||
- Dani Forga
|
||||
- Tris Doan \<<tridm@trobz.com>\>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
The migration from 16.0 to 17.0 of this module were financially supported by Camptocamp.
|
|
@ -379,7 +379,8 @@ when replying to a message from a customer.</p>
|
|||
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -413,10 +414,16 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Giuseppe Borruso <<a class="reference external" href="mailto:gborruso@dinamicheaziendali.it">gborruso@dinamicheaziendali.it</a>></li>
|
||||
<li>Laurence Labusch <<a class="reference external" href="mailto:lala@labiso.de">lala@labiso.de</a>></li>
|
||||
<li>Dani Forga</li>
|
||||
<li>Tris Doan <<a class="reference external" href="mailto:tridm@trobz.com">tridm@trobz.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
|
||||
<p>The migration from 16.0 to 17.0 of this module were financially
|
||||
supported by Camptocamp.</p>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
|
|
|
@ -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,
|
||||
});
|
|
@ -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));
|
||||
},
|
||||
});
|
|
@ -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");
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,32 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {registerPatch} from "@mail/model/model_core";
|
||||
|
||||
import rpc from "web.rpc";
|
||||
|
||||
registerPatch({
|
||||
name: "Message",
|
||||
|
||||
recordMethods: {
|
||||
messageReply() {
|
||||
var self = this,
|
||||
msg_id = this.id;
|
||||
rpc.query({
|
||||
model: "mail.message",
|
||||
method: "reply_message",
|
||||
args: [msg_id],
|
||||
}).then(function (result) {
|
||||
return self.env.services.action.doAction(
|
||||
result,
|
||||
|
||||
{
|
||||
onClose: async () => {
|
||||
self.originThread.fetchData(["messages"]);
|
||||
self.env.bus.trigger("update-messages");
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,30 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {one} from "@mail/model/model_field";
|
||||
import {registerPatch} from "@mail/model/model_core";
|
||||
|
||||
registerPatch({
|
||||
name: "MessageAction",
|
||||
fields: {
|
||||
replyMessageAction: one("MessageActionList", {
|
||||
identifying: true,
|
||||
inverse: "replyMessage",
|
||||
}),
|
||||
|
||||
messageActionListOwner: {
|
||||
compute() {
|
||||
if (this.replyMessageAction) {
|
||||
return this.replyMessageAction;
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
sequence: {
|
||||
compute() {
|
||||
return this.messageActionListOwner === this.replyMessageAction
|
||||
? 1
|
||||
: this._super();
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,26 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
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"];
|
||||
|
||||
export const isMessageTypeValid = (type) => {
|
||||
return MESSAGE_TYPES.includes(type);
|
||||
};
|
||||
|
||||
registerPatch({
|
||||
name: "MessageActionList",
|
||||
fields: {
|
||||
replyMessage: one("MessageAction", {
|
||||
compute() {
|
||||
if (this.message && isMessageTypeValid(this.message.message_type)) {
|
||||
return {};
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
inverse: "replyMessageAction",
|
||||
}),
|
||||
},
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {registerPatch} from "@mail/model/model_core";
|
||||
|
||||
registerPatch({
|
||||
name: "MessageActionView",
|
||||
recordMethods: {
|
||||
onClick(ev) {
|
||||
if (
|
||||
this.messageAction.messageActionListOwner ===
|
||||
this.messageAction.replyMessageAction
|
||||
) {
|
||||
this.messageAction.messageActionListOwner.message.messageReply();
|
||||
} else {
|
||||
this._super(ev);
|
||||
}
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
classNames: {
|
||||
compute() {
|
||||
let classNames = this._super() || "";
|
||||
if (
|
||||
this.messageAction.messageActionListOwner ===
|
||||
this.messageAction.replyMessageAction
|
||||
) {
|
||||
classNames += " fa fa-lg fa-reply";
|
||||
}
|
||||
return classNames;
|
||||
},
|
||||
},
|
||||
title: {
|
||||
compute() {
|
||||
if (
|
||||
this.messageAction.messageActionListOwner ===
|
||||
this.messageAction.replyMessageAction
|
||||
) {
|
||||
return this.env._t("Reply");
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue