|
|
@ -2,7 +2,7 @@ |
|
|
|
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) |
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
from openerp.tests import common |
|
|
|
from odoo.tests import common |
|
|
|
|
|
|
|
|
|
|
|
class TestMailOptionalFollowernotifications(common.TransactionCase): |
|
|
@ -11,8 +11,8 @@ class TestMailOptionalFollowernotifications(common.TransactionCase): |
|
|
|
super(TestMailOptionalFollowernotifications, self).setUp() |
|
|
|
self.partner_obj = self.env['res.partner'] |
|
|
|
self.partner_01 = self.env.ref('base.res_partner_2') |
|
|
|
self.partner_02 = self.env.ref('base.res_partner_3') |
|
|
|
self.partner_03 = self.env.ref('base.res_partner_4') |
|
|
|
self.demo_user = self.env.ref('base.user_demo') |
|
|
|
self.partner_03 = self.demo_user.copy().partner_id |
|
|
|
|
|
|
|
def test_send_email_optional_follower_notifications(self): |
|
|
|
ctx = self.env.context.copy() |
|
|
@ -22,10 +22,11 @@ class TestMailOptionalFollowernotifications(common.TransactionCase): |
|
|
|
'default_composition_mode': 'comment', |
|
|
|
}) |
|
|
|
mail_compose = self.env['mail.compose.message'] |
|
|
|
self.partner_01.message_subscribe_users(user_ids=[self.demo_user.id]) |
|
|
|
values = mail_compose.with_context(ctx)\ |
|
|
|
.onchange_template_id(False, 'comment', 'res.partner', |
|
|
|
self.partner_01.id)['value'] |
|
|
|
values['partner_ids'] = [(4, self.partner_02.id), |
|
|
|
values['partner_ids'] = [(4, self.demo_user.partner_id.id), |
|
|
|
(4, self.partner_03.id)] |
|
|
|
compose_id = mail_compose.with_context(ctx).create(values) |
|
|
|
compose_id.with_context(ctx).send_mail() |
|
|
@ -35,7 +36,7 @@ class TestMailOptionalFollowernotifications(common.TransactionCase): |
|
|
|
self.assertEqual(len(res.ids), 1) |
|
|
|
message = self.env['mail.message'] |
|
|
|
for record in res: |
|
|
|
if record.notified_partner_ids.ids == [self.partner_03.id] and\ |
|
|
|
if record.notification_ids.mapped('res_partner_id').ids == [self.partner_03.id] and\ |
|
|
|
record.partner_ids.ids == [self.partner_03.id]: |
|
|
|
message += record |
|
|
|
self.assertEqual(len(message.ids), 0) |
|
|
@ -48,7 +49,7 @@ class TestMailOptionalFollowernotifications(common.TransactionCase): |
|
|
|
('res_id', '=', self.partner_01.id)]) |
|
|
|
message = self.env['mail.message'] |
|
|
|
for record in res: |
|
|
|
if record.notified_partner_ids.ids == [self.partner_03.id] and\ |
|
|
|
if record.notification_ids.mapped('res_partner_id').ids == [self.partner_03.id] and\ |
|
|
|
record.partner_ids.ids == [self.partner_03.id]: |
|
|
|
message += record |
|
|
|
self.assertEqual(len(message.ids), 1) |