diff --git a/mail_quoted_reply/README.rst b/mail_quoted_reply/README.rst index 3d8a04f67b..a0e41df34c 100644 --- a/mail_quoted_reply/README.rst +++ b/mail_quoted_reply/README.rst @@ -31,6 +31,9 @@ Mail Message Reply This addon allow to reply on messages from odoo directly. It is useful when replying to a message from a customer. +Additionally, it is possible to separate the reply body from the mail body. +This separation is only for the composer and the sent mail will contain both parts. + **Table of contents** .. contents:: @@ -42,6 +45,10 @@ Usage On the messages from threads, a reply button is shown. Once it has been pressed, a composer with the reply is shown. +To activate the separation of the reply body add the system parameter "mail_quoted_reply.separate_reply_body". +After opening a composer with the reply button the reply body will be shown below the mail body as readonly. +To write into the reply body uncheck "Reply Readonly". For longer replies this can take some time. + Bug Tracker =========== diff --git a/mail_quoted_reply/__manifest__.py b/mail_quoted_reply/__manifest__.py index d4c898e560..29d055135e 100644 --- a/mail_quoted_reply/__manifest__.py +++ b/mail_quoted_reply/__manifest__.py @@ -10,7 +10,9 @@ "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/social", "depends": ["mail"], - "data": [], + "data": [ + "views/mail_compose_message_views.xml", + ], "assets": { "web.assets_backend": [ "/mail_quoted_reply/static/src/models/*.js", diff --git a/mail_quoted_reply/models/mail_compose_message.py b/mail_quoted_reply/models/mail_compose_message.py index af50226357..5db25f84ea 100644 --- a/mail_quoted_reply/models/mail_compose_message.py +++ b/mail_quoted_reply/models/mail_compose_message.py @@ -1,19 +1,49 @@ from markupsafe import Markup -from odoo import api, models, tools +from odoo import api, fields, models, tools class MailComposeMessage(models.TransientModel): _inherit = "mail.compose.message" + is_reply_readonly = fields.Boolean(default=True, string="Reply Readonly") + reply_body = fields.Html(default="", string="Reply body") + is_separate_body = fields.Boolean(compute="_compute_is_separate_body") + @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"]) + if self.is_separate_body: + self.reply_body = context["quote_body"] + else: + self.body += Markup(context["quote_body"]) return + @api.onchange("is_reply_readonly") + def _onchange_is_reply_readonly(self): + if self.reply_body: + self.reply_body = Markup(self.reply_body) + + @api.depends("reply_body") + def _compute_is_separate_body(self): + parameter_string = ( + self.env["ir.config_parameter"] + .sudo() + .get_param("mail_quoted_reply.separate_reply_body", "") + ) + self.is_separate_body = parameter_string.lower() not in ["", "false", "0"] + + def get_mail_values(self, res_ids): + results = super(MailComposeMessage, self).get_mail_values(res_ids) + if self.is_separate_body and self.reply_body: + for res_id in res_ids: + values = results.get(res_id) + reply_body = Markup(self.reply_body) + values.update({"body": values.get("body") + reply_body}) + return results + @api.model def get_record_data(self, values): result = super().get_record_data(values) diff --git a/mail_quoted_reply/readme/DESCRIPTION.rst b/mail_quoted_reply/readme/DESCRIPTION.rst index fbaa89bdca..aa6cdc676d 100644 --- a/mail_quoted_reply/readme/DESCRIPTION.rst +++ b/mail_quoted_reply/readme/DESCRIPTION.rst @@ -1,2 +1,5 @@ This addon allow to reply on messages from odoo directly. It is useful when replying to a message from a customer. + +Additionally, it is possible to separate the reply body from the mail body. +This separation is only for the composer and the sent mail will contain both parts. diff --git a/mail_quoted_reply/readme/USAGE.rst b/mail_quoted_reply/readme/USAGE.rst index 2a57635f4b..6cf62aefc0 100644 --- a/mail_quoted_reply/readme/USAGE.rst +++ b/mail_quoted_reply/readme/USAGE.rst @@ -1,2 +1,6 @@ On the messages from threads, a reply button is shown. Once it has been pressed, a composer with the reply is shown. + +To activate the separation of the reply body add the system parameter "mail_quoted_reply.separate_reply_body". +After opening a composer with the reply button the reply body will be shown below the mail body as readonly. +To write into the reply body uncheck "Reply Readonly". For longer replies this can take some time. diff --git a/mail_quoted_reply/static/description/index.html b/mail_quoted_reply/static/description/index.html index bc0dd8776b..eb51dc4914 100644 --- a/mail_quoted_reply/static/description/index.html +++ b/mail_quoted_reply/static/description/index.html @@ -371,6 +371,8 @@
This addon allow to reply on messages from odoo directly. It is useful when replying to a message from a customer.
+Additionally, it is possible to separate the reply body from the mail body. +This separation is only for the composer and the sent mail will contain both parts.
Table of contents
On the messages from threads, a reply button is shown. Once it has been pressed, a composer with the reply is shown.
+To activate the separation of the reply body add the system parameter “mail_quoted_reply.separate_reply_body”. +After opening a composer with the reply button the reply body will be shown below the mail body as readonly. +To write into the reply body uncheck “Reply Readonly”. For longer replies this can take some time.
demo message
" in wizard.reply_body) + wizard.action_send_mail() + new_message = partner.message_ids.filtered( + lambda r: r.message_type != "notification" and r != message + ) + self.assertTrue(new_message) + self.assertEqual(1, len(new_message)) + new_message = new_message[0] + self.assertTrue("demo message
" in new_message.body) diff --git a/mail_quoted_reply/views/mail_compose_message_views.xml b/mail_quoted_reply/views/mail_compose_message_views.xml new file mode 100644 index 0000000000..2acc8f7b05 --- /dev/null +++ b/mail_quoted_reply/views/mail_compose_message_views.xml @@ -0,0 +1,26 @@ + +