Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] mail_quoted_reply: Migration to 17.0 #1354

Open
wants to merge 36 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d3eeeb7
[ADD] mail_quoted_reply
etobella Apr 27, 2021
27aa79e
[IMP] black, isort, prettier
LoisRForgeFlow Jun 3, 2022
ba34ee0
[MIG] mail_quoted_reply: migration to version 13.0
LoisRForgeFlow Jun 3, 2022
13388c5
[UPD] Update mail_quoted_reply.pot
Jun 11, 2022
bf8a669
[UPD] README.rst
OCA-git-bot Jun 11, 2022
6d8f95e
[MIG] mail_quoted_reply: Migration to 14.0
jonasbuchholz Apr 4, 2022
140c9a5
[MIG] mail_quoted_reply: Migration to 15.0
jonasbuchholz Oct 4, 2022
c8265db
[UPD] Update mail_quoted_reply.pot
oca-travis Jun 22, 2022
79c2d54
[UPD] README.rst
OCA-git-bot Jun 22, 2022
8ddb3de
Added translation using Weblate (Catalan)
jabelchi Jul 4, 2022
d39b5d0
Added translation using Weblate (Spanish)
jabelchi Jul 4, 2022
dd4365c
Translated using Weblate (Catalan)
jabelchi Jul 4, 2022
3e7c949
Translated using Weblate (Spanish)
jabelchi Jul 4, 2022
a93b77c
[FIX] mail_quoted_reply: avoid access right errors when reading action.
LoisRForgeFlow Oct 3, 2022
15970ca
[FIX] mail_quoted_reply: add line breaks before block quote
jonasbuchholz Dec 13, 2022
0cb6849
[UPD] Update mail_quoted_reply.pot
Dec 15, 2022
dad156a
[UPD] README.rst
OCA-git-bot Dec 15, 2022
5b2d018
Update translation files
weblate Dec 15, 2022
7bcdfe5
[FIX] mail_quoted_reply: format of default m2m value in context (fixe…
StefanRijnhart Jan 13, 2023
5a9a1bc
mail_quoted_reply 15.0.1.0.1
OCA-git-bot Jan 24, 2023
fb1a287
[MIG] mail_quoted_reply: Migration to 16.0
Borruso Jun 14, 2023
8e8fc41
[MIG] mail_quoted_reply
llabusch93 Jun 28, 2023
bd3aba1
[IMP] Add functionality to include original subject in quoted reply
llabusch93 Jun 28, 2023
41a9383
15.0 - [IMP] mail_quoted_reply
Vulpino Jun 5, 2023
ea2e28e
[IMP] mail_quoted_reply: set email author as default reply partner
jonasbuchholz Jun 21, 2023
48cb234
[UPD] Update mail_quoted_reply.pot
Jan 9, 2024
fd58380
[BOT] post-merge updates
OCA-git-bot Jan 9, 2024
c500df9
Update translation files
weblate Jan 10, 2024
0b8fbbc
[FIX] mail_quoted_reply: Use standard paragraph element to enter text
grindtildeath Jan 9, 2024
80b3d6c
Translated using Weblate (Spanish)
Ivorra78 Jan 10, 2024
f012178
Added translation using Weblate (Italian)
mymage Jan 11, 2024
0cd1492
Translated using Weblate (Italian)
mymage Jan 11, 2024
5c778da
[BOT] post-merge updates
OCA-git-bot Jan 13, 2024
3069854
[IMP] mail_quoted_reply: pre-commit auto fixes
trisdoan Apr 12, 2024
adc2c86
[MIG] mail_quoted_reply: Migration to 17.0
trisdoan Apr 12, 2024
88e9b9d
fixup! [MIG] mail_quoted_reply: Migration to 17.0
trisdoan Jun 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it appears to depend on a context key, aren't we supposed to add this key in @api.depends_context() ?

composer.body = Markup(context["quote_body"])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be noted that when a user replies to a message and wants to load a template from the template_id field, the template must be added to the content that we already have in the body.
You can fix this with this code since the body in the creation of mail.compose.message is False.

if context.get("is_quoted_reply"): if composer.body: composer.body += Markup(context["quote_body"]) else: 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

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.

Loading