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

[18.0] [MIG] mail_quoted_reply: Migration to 18.0 #24

Open
wants to merge 28 commits into
base: 18.0
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4a5a665
[ADD] mail_quoted_reply
etobella Apr 27, 2021
f717484
[IMP] black, isort, prettier
LoisRForgeFlow Jun 3, 2022
654c559
[MIG] mail_quoted_reply: migration to version 13.0
LoisRForgeFlow Jun 3, 2022
1025a7d
[MIG] mail_quoted_reply: Migration to 14.0
jonasbuchholz Apr 4, 2022
de7caf5
[MIG] mail_quoted_reply: Migration to 15.0
jonasbuchholz Oct 4, 2022
a18ea89
Added translation using Weblate (Catalan)
jabelchi Jul 4, 2022
731ed34
Added translation using Weblate (Spanish)
jabelchi Jul 4, 2022
7846fef
Translated using Weblate (Catalan)
jabelchi Jul 4, 2022
18ca9ab
Translated using Weblate (Spanish)
jabelchi Jul 4, 2022
1838b36
[FIX] mail_quoted_reply: avoid access right errors when reading action.
LoisRForgeFlow Oct 3, 2022
33f9690
[FIX] mail_quoted_reply: add line breaks before block quote
jonasbuchholz Dec 13, 2022
785a192
[FIX] mail_quoted_reply: format of default m2m value in context (fixe…
StefanRijnhart Jan 13, 2023
cbb920b
[MIG] mail_quoted_reply: Migration to 16.0
Borruso Jun 14, 2023
6d3e570
[MIG] mail_quoted_reply
llabusch93 Jun 28, 2023
0ba378b
[IMP] Add functionality to include original subject in quoted reply
llabusch93 Jun 28, 2023
0a2d217
15.0 - [IMP] mail_quoted_reply
Vulpino Jun 5, 2023
fe9e5af
[IMP] mail_quoted_reply: set email author as default reply partner
jonasbuchholz Jun 21, 2023
03f3a63
[FIX] mail_quoted_reply: Use standard paragraph element to enter text
grindtildeath Jan 9, 2024
8aa2265
Translated using Weblate (Spanish)
Ivorra78 Jan 10, 2024
bdf68c0
Added translation using Weblate (Italian)
mymage Jan 11, 2024
2aa4093
Translated using Weblate (Italian)
mymage Jan 11, 2024
d400799
[IMP] mail_quoted_reply: pre-commit auto fixes
trisdoan Apr 12, 2024
315ea1a
[MIG] mail_quoted_reply: Migration to 17.0
trisdoan Apr 12, 2024
bb454d7
fixup! [MIG] mail_quoted_reply: Migration to 17.0
trisdoan Jun 2, 2024
213229b
fixup! [MIG] mail_quoted_reply: Migration to 17.0
Abranes Oct 4, 2024
2a0e7fb
[IMP] mail_quoted_reply: Sanitize HTML body before quoting
grindtildeath Nov 7, 2024
26f9e9e
[IMP] mail_quoted_reply: pre-commit auto fixes
Borruso Jan 23, 2025
1f02071
[MIG] mail_quoted_reply: Migration to 18.0
Borruso Jan 23, 2025
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
95 changes: 95 additions & 0 deletions mail_quoted_reply/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
==================
Mail Message Reply
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6759514c263e6b0b7f4bb8ad6aa6918552ba51bcbf32e0eda1f46dc4978ddbad
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github
:target: https://github.com/OCA/mail/tree/18.0/mail_quoted_reply
:alt: OCA/mail
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_quoted_reply
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon allow to reply on messages from odoo directly. It is useful
when replying to a message from a customer.

**Table of contents**

.. contents::
:local:

Usage
=====

On the messages from threads, a reply button is shown. Once it has been
pressed, a composer with the reply is shown.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_quoted_reply%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Creu Blanca

Contributors
------------

- Enric Tobella
- Lois Rilo <lois.rilo@forgeflow.com>
- Giuseppe Borruso <gborruso@dinamicheaziendali.it>
- Laurence Labusch <lala@labiso.de>
- Dani Forga
- Tris Doan <tridm@trobz.com>
- Akim Juillerat <akim.juillerat@camptocamp.com>

Other credits
-------------

The migration from 16.0 to 17.0 of this module were financially
supported by Camptocamp.

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/mail <https://github.com/OCA/mail/tree/18.0/mail_quoted_reply>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_quoted_reply/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions mail_quoted_reply/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Mail Message Reply",
"summary": """
Make a reply using a message""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/mail",
"depends": ["mail"],
"data": [],
"assets": {
"web.assets_backend": [
"/mail_quoted_reply/static/src/*.js",
],
},
}
93 changes: 93 additions & 0 deletions mail_quoted_reply/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_quoted_reply
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-07-04 15:05+0000\n"
"Last-Translator: jabelchi <jabelchi@gmail.com>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr ""

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Assistent de redacció d'emails"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "From"
msgstr ""

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_message
msgid "Message"
msgstr "Missatge"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr ""

#, python-format
#~ msgid "Reply"
#~ msgstr "Respon"

#~ msgid ""
#~ "\n"
#~ " <div>\n"
#~ " </div>\n"
#~ " <br/>\n"
#~ " <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\">\n"
#~ " From: ${object.email_from}<br/>\n"
#~ " Date: ${object.date}<br/>\n"
#~ " Subject: ${object.subject}<br/>\n"
#~ " ${object.body | safe}\n"
#~ " </blockquote>\n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " <div>\n"
#~ " </div>\n"
#~ " <br/>\n"
#~ " <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\">\n"
#~ " From: ${object.email_from}<br/>\n"
#~ " Date: ${object.date}<br/>\n"
#~ " Subject: ${object.subject}<br/>\n"
#~ " ${object.body | safe}\n"
#~ " </blockquote>\n"
#~ " "

#~ msgid "Display Name"
#~ msgstr "Nom a mostrar"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Darrera modificació el"

#~ msgid "Re: ${object.subject}"
#~ msgstr "Re: ${object.subject}"
93 changes: 93 additions & 0 deletions mail_quoted_reply/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_quoted_reply
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-10 19:33+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr "Fecha"

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Asistente composición Correo Electrónico"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "From"
msgstr "Desde"

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_message
msgid "Message"
msgstr "Mensaje"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr "Asunto"

#, python-format
#~ msgid "Reply"
#~ msgstr "Responder"

#~ msgid ""
#~ "\n"
#~ " <div>\n"
#~ " </div>\n"
#~ " <br/>\n"
#~ " <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\">\n"
#~ " From: ${object.email_from}<br/>\n"
#~ " Date: ${object.date}<br/>\n"
#~ " Subject: ${object.subject}<br/>\n"
#~ " ${object.body | safe}\n"
#~ " </blockquote>\n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " <div>\n"
#~ " </div>\n"
#~ " <br/>\n"
#~ " <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\">\n"
#~ " From: ${object.email_from}<br/>\n"
#~ " Date: ${object.date}<br/>\n"
#~ " Subject: ${object.subject}<br/>\n"
#~ " ${object.body | safe}\n"
#~ " </blockquote>\n"
#~ " "

#~ msgid "Display Name"
#~ msgstr "Nombre mostrado"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Última modificación el"

#~ msgid "Re: ${object.subject}"
#~ msgstr "Re: ${object.subject}"
52 changes: 52 additions & 0 deletions mail_quoted_reply/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_quoted_reply
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-11 08:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr "Data"

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Procedura guidata creazione e-mail"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "From"
msgstr "Dal"

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_message
msgid "Message"
msgstr "Messaggio"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr "Soggetto"

#, python-format
#~ msgid "Reply"
#~ msgstr "Rispondi"
45 changes: 45 additions & 0 deletions mail_quoted_reply/i18n/mail_quoted_reply.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_quoted_reply
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr ""

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_compose_message
msgid "Email composition wizard"
msgstr ""

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "From"
msgstr ""

#. module: mail_quoted_reply
#: model:ir.model,name:mail_quoted_reply.model_mail_message
msgid "Message"
msgstr ""

#. module: mail_quoted_reply
#. odoo-python
#: code:addons/mail_quoted_reply/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr ""
2 changes: 2 additions & 0 deletions mail_quoted_reply/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mail_message
from . import mail_compose_message
38 changes: 38 additions & 0 deletions mail_quoted_reply/models/mail_compose_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from markupsafe import Markup

from odoo import api, models, tools


class MailComposeMessage(models.TransientModel):
_inherit = "mail.compose.message"

@api.depends("composition_mode", "model", "res_domain", "res_ids", "template_id")
@api.depends_context("is_quoted_reply")
def _compute_body(self):
res = super()._compute_body()
for composer in self:
context = composer._context
if context.get("is_quoted_reply"):
if composer.body:
composer.body += Markup(context["quote_body"])

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

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L17

Added line #L17 was not covered by tests
else:
composer.body = Markup(context["quote_body"])
return res

@api.depends(
"composition_mode",
"model",
"parent_id",
"record_name",
"res_domain",
"res_ids",
"template_id",
)
@api.depends_context("default_subject")
def _compute_subject(self):
res = super()._compute_subject()

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

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L33

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

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

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L35

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

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

Codecov / codecov/patch

mail_quoted_reply/models/mail_compose_message.py#L37-L38

Added lines #L37 - L38 were not covered by tests
69 changes: 69 additions & 0 deletions mail_quoted_reply/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2021 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo.tools import format_datetime, html_sanitize


class MailMessage(models.Model):
_inherit = "mail.message"

def _get_sanitized_body(self):
self.ensure_one()
return html_sanitize(self.body)

def _prep_quoted_reply_body(self):
return """
<div style="margin: 0px; padding: 0px;">
<p style="margin:0px 0 12px 0;box-sizing:border-box;">
<br />
</p>
{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">
{str_from}: {email_from}<br/>
{str_date}: {date}<br/>
{str_subject}: {subject}<br/>
{body}
</blockquote>
</div>
""".format(
email_from=self.email_from,
date=format_datetime(self.env, self.date),
subject=self.subject,
body=self._get_sanitized_body(),
signature=self.env.user.signature,
str_date=_("Date"),
str_subject=_("Subject"),
str_from=_("From"),
)

def _default_reply_partner(self):
return self.env["res.partner"].find_or_create(self.email_from).ids

def reply_message(self):
action = self.env["ir.actions.actions"]._for_xml_id(
"mail.action_email_compose_message_wizard"
)
action["context"] = {
"default_model": self.model,
"default_res_ids": [self.res_id],
"default_composition_mode": "comment",
"quote_body": self._prep_quoted_reply_body(),
"default_is_log": False,
"is_log": False,
"is_quoted_reply": True,
"default_notify": True,
"force_email": True,
"default_partner_ids": self._default_reply_partner(),
}

# If the original message had a subject, we use it as a base for the
# new subject, adding a "Re:" at the beginning.
if self.subject:
action["context"]["default_subject"] = f"Re: {self.subject}"

return action
3 changes: 3 additions & 0 deletions mail_quoted_reply/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions mail_quoted_reply/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Enric Tobella
- Lois Rilo \<<lois.rilo@forgeflow.com>\>
- Giuseppe Borruso \<<gborruso@dinamicheaziendali.it>\>
- Laurence Labusch \<<lala@labiso.de>\>
- Dani Forga
- Tris Doan \<<tridm@trobz.com>\>
- Akim Juillerat \<<akim.juillerat@camptocamp.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.
2 changes: 2 additions & 0 deletions mail_quoted_reply/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This addon allow to reply on messages from odoo directly. It is useful
when replying to a message from a customer.
2 changes: 2 additions & 0 deletions mail_quoted_reply/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On the messages from threads, a reply button is shown. Once it has been
pressed, a composer with the reply is shown.
Binary file added mail_quoted_reply/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
442 changes: 442 additions & 0 deletions mail_quoted_reply/static/description/index.html

Large diffs are not rendered by default.

8 changes: 8 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,8 @@
import {messageActionsRegistry} from "@mail/core/common/message_actions";

messageActionsRegistry.add("reply", {
icon: "fa fa-reply",
title: "Reply",
onClick: (component) => component.message.messageReply(component.props.message),
condition: (component) => component.canReply,
});
22 changes: 22 additions & 0 deletions mail_quoted_reply/static/src/message_model.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Message} from "@mail/core/common/message_model";
import {patch} from "@web/core/utils/patch";

patch(Message.prototype, {
async messageReply(message) {
var self = this;
const thread = message.thread;
await this.store.env.services.orm
.call("mail.message", "reply_message", [message.id])
.then(function (result) {
return self.store.env.services.action.doAction(result, {
onClose: async () => {
await self.store.env.services["mail.store"].Thread.getOrFetch(
thread,
["messages"]
);
self.store.env.bus.trigger("update-messages");
},
});
});
},
});
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 @@
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.message_type)
);
},
});
1 change: 1 addition & 0 deletions mail_quoted_reply/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_reply
46 changes: 46 additions & 0 deletions mail_quoted_reply/tests/test_reply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2021 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import re

from odoo.tests import TransactionCase


class TestMessageReply(TransactionCase):
def test_reply(self):
partner = self.env["res.partner"].create({"name": "demo partner"})
self.assertFalse(
partner.message_ids.filtered(lambda r: r.message_type != "notification")
)
# pylint: disable=C8107
message = partner.message_post(
body="demo message",
message_type="email",
partner_ids=self.env.ref("base.partner_demo").ids,
)
partner.invalidate_recordset()
self.assertIn(
message,
partner.message_ids.filtered(lambda r: r.message_type != "notification"),
)
self.assertFalse(
partner.message_ids.filtered(
lambda r: r.message_type != "notification" and r != message
)
)
action = message.reply_message()
wizard = (
self.env[action["res_model"]].with_context(**action["context"]).create({})
)
self.assertTrue(wizard.partner_ids)
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
# the onchange in the composer isn't triggered in tests, so we check for the
# correct quote in the context
email_quote = re.search("<p>.*?</p>", wizard._context["quote_body"]).group()
self.assertEqual("<p>demo message</p>", email_quote)
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))