diff --git a/mail_usability/__openerp__.py b/mail_usability/__openerp__.py index 3be53b1..1a47d07 100644 --- a/mail_usability/__openerp__.py +++ b/mail_usability/__openerp__.py @@ -23,7 +23,7 @@ { 'name': 'Mail Usability', - 'version': '0.1', + 'version': '8.0.1.0.0', 'category': 'Base', 'license': 'AGPL-3', 'summary': 'Usability improvements on mails', @@ -37,6 +37,7 @@ Small usability improvements on mails: * remove 'sent by' in notification footer +* add a new entry *All Messages Except Notifications* to the field *Receive Inbox Notifications by Email* of partners (becomes the default value) """, 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/mail_usability/mail.py b/mail_usability/mail.py index 154045f..5298d91 100644 --- a/mail_usability/mail.py +++ b/mail_usability/mail.py @@ -20,7 +20,16 @@ # ############################################################################## -from openerp import models, api +from openerp import models, fields, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + notify_email = fields.Selection( + selection_add=[ + ('all_except_notification', 'All Messages Except Notifications')], + default='all_except_notification') class MailMail(models.Model): @@ -50,3 +59,15 @@ class MailNotification(models.Model): footer = footer[:footer.find('\n
Sent by ')] footer = footer[:footer.find(u'\n
Envoyé par ')] return footer + + @api.multi + def get_partners_to_email(self, message): + notify_pids = super(MailNotification, self).get_partners_to_email( + message) + for notif in self: + if ( + message.type == 'notification' and + notif.partner_id.notify_email == + 'all_except_notification'): + notify_pids.remove(notif.partner_id.id) + return notify_pids