Add "All Messages Except Notifications" for notify_email on res.partner

This commit is contained in:
Alexis de Lattre
2017-06-21 14:52:47 +02:00
parent d736663f3f
commit db736d95a3
2 changed files with 24 additions and 2 deletions

View File

@@ -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',

View File

@@ -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<br /><small>Sent by ')]
footer = footer[:footer.find(u'\n<br /><small>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