From 4168930283497ab7c52e8c1c66ef43d01ecb273b Mon Sep 17 00:00:00 2001
From: Holger Brunn
Date: Wed, 24 Jul 2019 11:46:24 +0200
Subject: [PATCH] [FIX] don't break when a partner has a user
---
.../models/mail_notification.py | 4 ++++
.../tests/test_mail_notification_email_template.py | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/mail_notification_email_template/models/mail_notification.py b/mail_notification_email_template/models/mail_notification.py
index 8657c480b..849ce53cc 100644
--- a/mail_notification_email_template/models/mail_notification.py
+++ b/mail_notification_email_template/models/mail_notification.py
@@ -68,3 +68,7 @@ class MailNotification(models.Model):
)
for a in etree.HTML(link_html or '').xpath('//a[@href]'):
this.record_access_link = a.get('href')
+
+ @api.model
+ def _get_access_link(self, mail, partner):
+ return self.env['mail.thread']._get_access_link(mail, partner)
diff --git a/mail_notification_email_template/tests/test_mail_notification_email_template.py b/mail_notification_email_template/tests/test_mail_notification_email_template.py
index f9a2edd56..75d5c6b3c 100644
--- a/mail_notification_email_template/tests/test_mail_notification_email_template.py
+++ b/mail_notification_email_template/tests/test_mail_notification_email_template.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+from mock import patch
from openerp.tests.common import TransactionCase
@@ -22,3 +23,9 @@ class TestMailNotificationEmailTemplate(TransactionCase):
self.assertTrue(notifications)
# check that our template was used
self.assertTrue('Dear ' in n.body for n in notifications)
+ # check we can actually send our mail
+ with patch.object(
+ self.env['ir.mail_server'].__class__, 'send_email'
+ ) as mock_send_email:
+ notifications.send()
+ mock_send_email.assert_called()