From af78d4f694568c59b5cc4e9eaf6950ac8f684ec3 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Wed, 25 May 2016 15:34:16 +0200 Subject: [PATCH] mail.notification has been removed. The notify is done directly on the res.partner and channel --- .../models/__init__.py | 2 +- .../models/mail_notification.py | 19 ------------------- .../models/res_partner.py | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 20 deletions(-) delete mode 100644 mail_optional_follower_notification/models/mail_notification.py create mode 100644 mail_optional_follower_notification/models/res_partner.py diff --git a/mail_optional_follower_notification/models/__init__.py b/mail_optional_follower_notification/models/__init__.py index cc213b9fc..0c4de3219 100644 --- a/mail_optional_follower_notification/models/__init__.py +++ b/mail_optional_follower_notification/models/__init__.py @@ -3,4 +3,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import mail_message -from . import mail_notification +from . import res_partner diff --git a/mail_optional_follower_notification/models/mail_notification.py b/mail_optional_follower_notification/models/mail_notification.py deleted file mode 100644 index 47cf08b6a..000000000 --- a/mail_optional_follower_notification/models/mail_notification.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import models, api - - -class MailNotification(models.Model): - _inherit = 'mail.notification' - - @api.model - def _notify(self, message_id, partners_to_notify=None, - force_send=False, user_signature=True): - if self.env.context.get('force_partners_to_notify'): - partners_to_notify =\ - self.env.context.get('force_partners_to_notify') - super(MailNotification, self)._notify( - message_id, partners_to_notify=partners_to_notify, - force_send=force_send, user_signature=user_signature) diff --git a/mail_optional_follower_notification/models/res_partner.py b/mail_optional_follower_notification/models/res_partner.py new file mode 100644 index 000000000..4c7e53f49 --- /dev/null +++ b/mail_optional_follower_notification/models/res_partner.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.multi + def _notify(self, message, force_send=False, user_signature=True): + if self.env.context.get('force_partners_to_notify'): + partners_to_notify =\ + self.env.context.get('force_partners_to_notify') + self = self.filtered(lambda p: p.id in partners_to_notify) + super(ResPartner, self)._notify( + message, force_send=False, user_signature=True)