Skip to content

Commit

Permalink
[MIG] mail_quoted_reply: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed May 2, 2024
1 parent 3069854 commit adc2c86
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 153 deletions.
7 changes: 7 additions & 0 deletions mail_quoted_reply/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down
4 changes: 2 additions & 2 deletions mail_quoted_reply/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"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",
"depends": ["mail"],
"data": [],
"assets": {
"web.assets_backend": [
"/mail_quoted_reply/static/src/models/*.js",
"/mail_quoted_reply/static/src/*.js",
],
},
}
38 changes: 24 additions & 14 deletions mail_quoted_reply/models/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@
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()

Check warning on line 28 in mail_quoted_reply/models/mail_compose_message.py

View check run for this annotation

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L28

Added line #L28 was not covered by tests
for composer in self:
subj = composer._context.get("default_subject", False)

Check warning on line 30 in mail_quoted_reply/models/mail_compose_message.py

View check run for this annotation

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L30

Added line #L30 was not covered by tests
if subj:
composer.subject = tools.ustr(subj)
return res

Check warning on line 33 in mail_quoted_reply/models/mail_compose_message.py

View check run for this annotation

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L32-L33

Added lines #L32 - L33 were not covered by tests
7 changes: 4 additions & 3 deletions mail_quoted_reply/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def _prep_quoted_reply_body(self):
{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/>
Expand All @@ -45,7 +46,7 @@ def reply_message(self):
)
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,
Expand Down
1 change: 1 addition & 0 deletions mail_quoted_reply/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Giuseppe Borruso \<<gborruso@dinamicheaziendali.it>\>
- Laurence Labusch \<<lala@labiso.de>\>
- Dani Forga
- Tris Doan \<<tridm@trobz.com>\>
1 change: 1 addition & 0 deletions mail_quoted_reply/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration from 16.0 to 17.0 of this module were financially supported by Camptocamp.
11 changes: 9 additions & 2 deletions mail_quoted_reply/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ <h1 class="title">Mail Message Reply</h1>
<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>
Expand Down Expand Up @@ -413,10 +414,16 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Giuseppe Borruso &lt;<a class="reference external" href="mailto:gborruso&#64;dinamicheaziendali.it">gborruso&#64;dinamicheaziendali.it</a>&gt;</li>
<li>Laurence Labusch &lt;<a class="reference external" href="mailto:lala&#64;labiso.de">lala&#64;labiso.de</a>&gt;</li>
<li>Dani Forga</li>
<li>Tris Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</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
Expand Down
11 changes: 11 additions & 0 deletions mail_quoted_reply/static/src/message_actions.esm.js
Original file line number Diff line number Diff line change
@@ -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,
});
20 changes: 20 additions & 0 deletions mail_quoted_reply/static/src/message_patch.esm.js
Original file line number Diff line number Diff line change
@@ -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));
},
});
29 changes: 29 additions & 0 deletions mail_quoted_reply/static/src/message_service.esm.js
Original file line number Diff line number Diff line change
@@ -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");
},
});
});
},
});
32 changes: 0 additions & 32 deletions mail_quoted_reply/static/src/models/message.esm.js

This file was deleted.

30 changes: 0 additions & 30 deletions mail_quoted_reply/static/src/models/message_action.esm.js

This file was deleted.

26 changes: 0 additions & 26 deletions mail_quoted_reply/static/src/models/message_action_list.esm.js

This file was deleted.

44 changes: 0 additions & 44 deletions mail_quoted_reply/static/src/models/message_action_view.esm.js

This file was deleted.

0 comments on commit adc2c86

Please sign in to comment.