Skip to content

Commit

Permalink
[MIG] mail_notification_with_history: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Oct 28, 2024
1 parent ca4570f commit 76023ba
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 22 deletions.
7 changes: 7 additions & 0 deletions mail_notification_with_history/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ Contributors
- `Camptocamp <https://www.camptocamp.com>`__

- Thierry Ducrest <thierry.ducrest@camptocamp.com>
- Tris Doan <tridm@trobz.com>

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

The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions mail_notification_with_history/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{
"name": "Mail Notification With History",
"summary": """Add the previous chatter discussion into new email notifications.""",
"version": "14.0.1.0.1",
"category": "Social",
"version": "18.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
Expand Down
14 changes: 5 additions & 9 deletions mail_notification_with_history/data/mail_data.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<template
id="message_notification_email"
inherit_id="mail.message_notification_email"
id="mail_notification_with_history.mail_notification_layout"
inherit_id="mail.mail_notification_layout"
>
<xpath expr="//div[@t-if='signature']" position="after">

<xpath expr="//div[@t-out='signature']" position="after">
<t
t-set="message_history"
t-value="message._get_notification_message_history()"
Expand All @@ -16,16 +14,14 @@
<ul>
<t t-foreach="message_history" t-as="msg">
<li class="message_history_item">
<p><t t-esc="msg.author_id.name or 'unknown'" /> commented on <span
<p><t t-out="msg.author_id.name or 'unknown'" /> commented on <span
t-field="msg.date"
/></p>
<div t-raw="msg.body" />
<div t-out="msg.body" />
</li>
</t>
</ul>
</t>

</xpath>
</template>

</odoo>
1 change: 1 addition & 0 deletions mail_notification_with_history/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- [Camptocamp](https://www.camptocamp.com)

> - Thierry Ducrest \<<thierry.ducrest@camptocamp.com>\>
> - Tris Doan \<<tridm@trobz.com>\>
1 change: 1 addition & 0 deletions mail_notification_with_history/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp.
11 changes: 9 additions & 2 deletions mail_notification_with_history/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ <h1 class="title">Mail Notification With History</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 @@ -417,13 +418,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<blockquote>
<ul class="simple">
<li>Thierry Ducrest &lt;<a class="reference external" href="mailto:thierry.ducrest&#64;camptocamp.com">thierry.ducrest&#64;camptocamp.com</a>&gt;</li>
<li>Tris Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</blockquote>
</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 of this module from 14.0 to 18.0 was 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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from unittest.mock import Mock, patch

from odoo.tests import common
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo


class TestMailNotificationWithHistory(common.SavepointCase):
class TestMailNotificationWithHistory(SavepointCaseWithUserDemo):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.base_template = cls.env.ref("mail.message_notification_email")
cls.base_template = cls.env.ref("mail.mail_notification_layout")
cls.mail_message = cls.env.ref("mail.mail_message_channel_1_2_1")
cls.message_subtype = cls.env.ref("mail.mt_comment")
cls.render_values = {
Expand All @@ -33,16 +33,20 @@ def test_thread_history_is_included(self):
),
new=Mock(return_value=True),
):
body = self.base_template._render(
self.render_values, engine="ir.qweb", minimal_qcontext=True
body = self.env["ir.qweb"]._render(
"mail.mail_notification_layout",
self.render_values,
minimal_qcontext=True,
)
self.assertTrue(body.find(b"Discussion") >= 0)
self.assertTrue(body.find("Discussion") >= 0)

def test_thread_history_is_not_included(self):
body = self.base_template._render(
self.render_values, engine="ir.qweb", minimal_qcontext=True
body = self.env["ir.qweb"]._render(
"mail.mail_notification_layout",
self.render_values,
minimal_qcontext=True,
)
self.assertTrue(body.find(b"Discussion") == -1)
self.assertTrue(body.find("Discussion") == -1)

def test_domain_message_in_history(self):
"""Check the good number of message is returned for the history."""
Expand Down

0 comments on commit 76023ba

Please sign in to comment.