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>
26 lines
758 B
Python
26 lines
758 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models
|
|
from odoo import api
|
|
|
|
|
|
class MailThread(models.AbstractModel):
|
|
_inherit = 'mail.thread'
|
|
|
|
def _notify_cancel_snail(self):
|
|
author_id = self.env.user.id
|
|
letters = self.env['snailmail.letter'].search([
|
|
('state', 'not in', ['sent', 'canceled', 'pending']),
|
|
('user_id', '=', author_id),
|
|
('model', '=', self._name)
|
|
])
|
|
letters.cancel()
|
|
|
|
@api.model
|
|
def notify_cancel_by_type(self, notification_type):
|
|
super().notify_cancel_by_type(notification_type)
|
|
if notification_type == 'snail':
|
|
self._notify_cancel_snail()
|
|
return True
|