Skip to content

Commit ec6ef71

Browse files
mathiasfranckemuaazsiddiq
authored andcommitted
[MIG] mail_quoted_reply: Migration to version 19
1 parent ec76264 commit ec6ef71

File tree

10 files changed

+129
-38
lines changed

10 files changed

+129
-38
lines changed

mail_quoted_reply/README.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
==================
26
Mail Message Reply
37
==================
@@ -13,17 +17,17 @@ Mail Message Reply
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github
20-
:target: https://github.com/OCA/mail/tree/18.0/mail_quoted_reply
24+
:target: https://github.com/OCA/mail/tree/19.0/mail_quoted_reply
2125
:alt: OCA/mail
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_quoted_reply
27+
:target: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_quoted_reply
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -48,7 +52,7 @@ Bug Tracker
4852
Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/issues>`_.
4953
In case of trouble, please check there if your issue has already been reported.
5054
If you spotted it first, help us to smash it by providing a detailed and welcomed
51-
`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**>`_.
55+
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_quoted_reply%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5256

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

@@ -74,8 +78,7 @@ Contributors
7478
Other credits
7579
-------------
7680

77-
The migration from 16.0 to 17.0 of this module were financially
78-
supported by Camptocamp.
81+
7982

8083
Maintainers
8184
-----------
@@ -90,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
9093
mission is to support the collaborative development of Odoo features and
9194
promote its widespread use.
9295

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

9598
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

mail_quoted_reply/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import models
2+
from . import wizard

mail_quoted_reply/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Mail Message Reply",
66
"summary": """
77
Make a reply using a message""",
8-
"version": "18.0.1.0.0",
8+
"version": "19.0.1.0.0",
99
"license": "AGPL-3",
1010
"author": "Creu Blanca,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/mail",
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from . import mail_message
2-
from . import mail_compose_message

mail_quoted_reply/models/mail_message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2021 Creu Blanca
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33

4-
from odoo import _, models
4+
from odoo import models
55
from odoo.tools import format_datetime, html_sanitize
66

77

@@ -36,9 +36,9 @@ def _prep_quoted_reply_body(self):
3636
subject=self.subject,
3737
body=self._get_sanitized_body(),
3838
signature=self.env.user.signature,
39-
str_date=_("Date"),
40-
str_subject=_("Subject"),
41-
str_from=_("From"),
39+
str_date=self.env._("Date"),
40+
str_subject=self.env._("Subject"),
41+
str_from=self.env._("From"),
4242
)
4343

4444
def _default_reply_partner(self):
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
The migration from 16.0 to 17.0 of this module were financially supported by Camptocamp.

mail_quoted_reply/static/description/index.html

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Mail Message Reply</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="mail-message-reply">
364-
<h1 class="title">Mail Message Reply</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="mail-message-reply">
370+
<h1>Mail Message Reply</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:f14d84d07497de8061c90082adea9bd9799e7a75ea6e2e84b2531ad387f6c8fd
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_quoted_reply"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_quoted_reply"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/19.0/mail_quoted_reply"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_quoted_reply"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This addon allow to reply on messages from odoo directly. It is useful
374379
when replying to a message from a customer.</p>
375380
<p><strong>Table of contents</strong></p>
@@ -387,28 +392,28 @@ <h1 class="title">Mail Message Reply</h1>
387392
</ul>
388393
</div>
389394
<div class="section" id="usage">
390-
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
395+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
391396
<p>On the messages from threads, a reply button is shown. Once it has been
392397
pressed, a composer with the reply is shown.</p>
393398
</div>
394399
<div class="section" id="bug-tracker">
395-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
400+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
396401
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/mail/issues">GitHub Issues</a>.
397402
In case of trouble, please check there if your issue has already been reported.
398403
If you spotted it first, help us to smash it by providing a detailed and welcomed
399-
<a class="reference external" href="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**">feedback</a>.</p>
404+
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_quoted_reply%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
400405
<p>Do not contact contributors directly about support or help with technical issues.</p>
401406
</div>
402407
<div class="section" id="credits">
403-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
408+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
404409
<div class="section" id="authors">
405-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
410+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
406411
<ul class="simple">
407412
<li>Creu Blanca</li>
408413
</ul>
409414
</div>
410415
<div class="section" id="contributors">
411-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
416+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
412417
<ul class="simple">
413418
<li>Enric Tobella</li>
414419
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
@@ -420,23 +425,22 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
420425
</ul>
421426
</div>
422427
<div class="section" id="other-credits">
423-
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
424-
<p>The migration from 16.0 to 17.0 of this module were financially
425-
supported by Camptocamp.</p>
428+
<h3><a class="toc-backref" href="#toc-entry-6">Other credits</a></h3>
426429
</div>
427430
<div class="section" id="maintainers">
428-
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
431+
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
429432
<p>This module is maintained by the OCA.</p>
430433
<a class="reference external image-reference" href="https://odoo-community.org">
431434
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
432435
</a>
433436
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
434437
mission is to support the collaborative development of Odoo features and
435438
promote its widespread use.</p>
436-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/18.0/mail_quoted_reply">OCA/mail</a> project on GitHub.</p>
439+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/19.0/mail_quoted_reply">OCA/mail</a> project on GitHub.</p>
437440
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
438441
</div>
439442
</div>
440443
</div>
444+
</div>
441445
</body>
442446
</html>

mail_quoted_reply/tests/test_reply.py

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77

88

99
class TestMessageReply(TransactionCase):
10-
def test_reply(self):
10+
def test_quoted_reply(self):
1111
partner = self.env["res.partner"].create({"name": "demo partner"})
1212
self.assertFalse(
1313
partner.message_ids.filtered(lambda r: r.message_type != "notification")
1414
)
1515
# pylint: disable=C8107
1616
message = partner.message_post(
1717
body="demo message",
18+
subject="demo subject",
1819
message_type="email",
19-
partner_ids=self.env.ref("base.partner_demo").ids,
20+
partner_ids=self.env.ref("base.partner_admin").ids,
2021
)
2122
partner.invalidate_recordset()
2223
self.assertIn(
@@ -34,9 +35,92 @@ def test_reply(self):
3435
)
3536
self.assertTrue(wizard.partner_ids)
3637
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
38+
self.assertEqual(action["context"]["default_subject"], "Re: demo subject")
3739
# the onchange in the composer isn't triggered in tests, so we check for the
3840
# correct quote in the context
39-
email_quote = re.search("<p>.*?</p>", wizard._context["quote_body"]).group()
41+
email_quote = re.search("<p>.*?</p>", wizard.env.context["quote_body"]).group()
42+
self.assertEqual("<p>demo message</p>", email_quote)
43+
wizard.action_send_mail()
44+
new_message = partner.message_ids.filtered(
45+
lambda r: r.message_type != "notification" and r != message
46+
)
47+
self.assertTrue(new_message)
48+
self.assertEqual(1, len(new_message))
49+
50+
def test_unquoted_reply(self):
51+
partner = self.env["res.partner"].create({"name": "demo partner"})
52+
self.assertFalse(
53+
partner.message_ids.filtered(lambda r: r.message_type != "notification")
54+
)
55+
# pylint: disable=C8107
56+
message = partner.message_post(
57+
body="demo message",
58+
message_type="email",
59+
partner_ids=self.env.ref("base.partner_admin").ids,
60+
)
61+
partner.invalidate_recordset()
62+
self.assertIn(
63+
message,
64+
partner.message_ids.filtered(lambda r: r.message_type != "notification"),
65+
)
66+
self.assertFalse(
67+
partner.message_ids.filtered(
68+
lambda r: r.message_type != "notification" and r != message
69+
)
70+
)
71+
action = message.reply_message()
72+
action["context"]["is_quoted_reply"] = False
73+
wizard = (
74+
self.env[action["res_model"]].with_context(**action["context"]).create({})
75+
)
76+
wizard = wizard.with_context(
77+
default_subject="Some subject for testing purposes",
78+
)
79+
self.assertTrue(wizard.partner_ids)
80+
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
81+
# the onchange in the composer isn't triggered in tests, so we check for the
82+
# correct quote in the context
83+
email_quote = re.search("<p>.*?</p>", wizard.env.context["quote_body"]).group()
84+
self.assertEqual("<p>demo message</p>", email_quote)
85+
wizard.action_send_mail()
86+
new_message = partner.message_ids.filtered(
87+
lambda r: r.message_type != "notification" and r != message
88+
)
89+
self.assertTrue(new_message)
90+
self.assertEqual(1, len(new_message))
91+
92+
def test_reply_with_existing_body(self):
93+
partner = self.env["res.partner"].create({"name": "demo partner"})
94+
self.assertFalse(
95+
partner.message_ids.filtered(lambda r: r.message_type != "notification")
96+
)
97+
# pylint: disable=C8107
98+
message = partner.message_post(
99+
body="demo message",
100+
message_type="email",
101+
partner_ids=self.env.ref("base.partner_admin").ids,
102+
)
103+
partner.invalidate_recordset()
104+
self.assertIn(
105+
message,
106+
partner.message_ids.filtered(lambda r: r.message_type != "notification"),
107+
)
108+
self.assertFalse(
109+
partner.message_ids.filtered(
110+
lambda r: r.message_type != "notification" and r != message
111+
)
112+
)
113+
action = message.reply_message()
114+
action["context"]["is_quoted_reply"] = False
115+
wizard = (
116+
self.env[action["res_model"]].with_context(**action["context"]).create({})
117+
)
118+
wizard.body = "Some body for testing purposes"
119+
self.assertTrue(wizard.partner_ids)
120+
self.assertEqual(message.email_from, wizard.partner_ids.email_formatted)
121+
# the onchange in the composer isn't triggered in tests, so we check for the
122+
# correct quote in the context
123+
email_quote = re.search("<p>.*?</p>", wizard.env.context["quote_body"]).group()
40124
self.assertEqual("<p>demo message</p>", email_quote)
41125
wizard.action_send_mail()
42126
new_message = partner.message_ids.filtered(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import mail_compose_message

mail_quoted_reply/models/mail_compose_message.py renamed to mail_quoted_reply/wizard/mail_compose_message.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from markupsafe import Markup
22

3-
from odoo import api, models, tools
3+
from odoo import api, models
44

55

66
class MailComposeMessage(models.TransientModel):
@@ -11,7 +11,7 @@ class MailComposeMessage(models.TransientModel):
1111
def _compute_body(self):
1212
res = super()._compute_body()
1313
for composer in self:
14-
context = composer._context
14+
context = composer.env.context
1515
if context.get("is_quoted_reply"):
1616
if composer.body:
1717
composer.body += Markup(context["quote_body"])
@@ -23,7 +23,6 @@ def _compute_body(self):
2323
"composition_mode",
2424
"model",
2525
"parent_id",
26-
"record_name",
2726
"res_domain",
2827
"res_ids",
2928
"template_id",
@@ -32,7 +31,8 @@ def _compute_body(self):
3231
def _compute_subject(self):
3332
res = super()._compute_subject()
3433
for composer in self:
35-
subj = composer._context.get("default_subject", False)
34+
context = composer.env.context
35+
subj = context.get("default_subject", False)
3636
if subj:
37-
composer.subject = tools.ustr(subj)
37+
composer.subject = str(subj)
3838
return res

0 commit comments

Comments
 (0)