Files
odoo_source/addons/test_mail/tests/test_mail_management.py
T
Pierre-Yves Dufays eca543ef40 [REM] mail, sms, snailmail: discard notifications without confirmation
Skip the confirmation step when wanting to get rid of a notification
for emails, sms or letters that were not sent.

Technical:
- All 3 wizards to confirm the discarding of the notification have been removed
(the ones for mail, sms and letter) have been removed
- The method to discard notification has been centralized in MailThread
(notify_cancel_by_type in addons/mail/models/mail_thread.py)
- This centralization has been done as well on the client code as the same
server code is called whether it is a mail, a sms or a letter
(in addons/mail/static/src/models/notification_group/notification_group.js)
- Existing front and back test have been adapted
- A test of notify_cancel_by_type for mail has been added
(addons/test_mail/tests/test_mail_management.py)
- add missing author_id in mail_notification demo data

Task-2752190

closes odoo/odoo#84452

Related: odoo/upgrade#3246
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-01 17:56:20 +02:00

54 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.tests import tagged
@tagged('mail_management')
class TestMailManagement(TestMailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
super(TestMailManagement, cls).setUpClass()
cls.test_record = cls.env['mail.test.simple'].with_context(cls._test_context).create({'name': 'Test'})
cls._reset_mail_context(cls.test_record)
cls.msg = cls.test_record.message_post(body='TEST BODY', author_id=cls.partner_employee.id)
cls.notif_p1 = cls.env['mail.notification'].create({
'author_id': cls.msg.author_id.id,
'mail_message_id': cls.msg.id,
'res_partner_id': cls.partner_1.id,
'notification_type': 'email',
'notification_status': 'exception',
'failure_type': 'mail_smtp',
})
cls.notif_p2 = cls.env['mail.notification'].create({
'author_id': cls.msg.author_id.id,
'mail_message_id': cls.msg.id,
'res_partner_id': cls.partner_2.id,
'notification_type': 'email',
'notification_status': 'bounce',
'failure_type': 'unknown',
})
cls.partner_3 = cls.env['res.partner'].create({
'name': 'Partner3',
'email': 'partner3@example.com',
})
cls.notif_p3 = cls.env['mail.notification'].create({
'author_id': cls.msg.author_id.id,
'mail_message_id': cls.msg.id,
'res_partner_id': cls.partner_3.id,
'notification_type': 'email',
'notification_status': 'sent',
'failure_type': None,
})
def test_mail_notify_cancel(self):
self._reset_bus()
self.test_record.with_user(self.user_employee).notify_cancel_by_type('email')
self.assertEqual((self.notif_p1 | self.notif_p2 | self.notif_p3).mapped('notification_status'),
['canceled', 'canceled', 'sent'])
self.assertMessageBusNotifications(self.msg)