-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
base: 17.0
Are you sure you want to change the base?
Changes from 1 commit
d3eeeb7
27aa79e
ba34ee0
13388c5
bf8a669
6d8f95e
140c9a5
c8265db
79c2d54
8ddb3de
d39b5d0
dd4365c
3e7c949
a93b77c
15970ca
0cb6849
dad156a
5b2d018
7bcdfe5
5a9a1bc
fb1a287
8e8fc41
bd3aba1
41a9383
ea2e28e
48cb234
fd58380
c500df9
0b8fbbc
80b3d6c
f012178
0cd1492
5c778da
3069854
adc2c86
88e9b9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
if subj: | ||
composer.subject = tools.ustr(subj) | ||
return res | ||
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. |
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, | ||
}); |
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)); | ||
}, | ||
}); |
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"); | ||
}, | ||
}); | ||
}); | ||
}, | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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()
?