2010-06-25 09:50:38 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2013-05-15 15:31:59 +00:00
|
|
|
|
2013-02-28 16:40:54 +00:00
|
|
|
from openerp.tools.translate import _
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
2010-06-25 09:50:38 +00:00
|
|
|
|
2013-02-28 16:40:54 +00:00
|
|
|
|
2012-08-14 18:49:56 +00:00
|
|
|
class res_partner_mail(osv.Model):
|
2012-08-23 13:11:44 +00:00
|
|
|
""" Update partner to add a field about notification preferences """
|
2012-05-07 12:42:27 +00:00
|
|
|
_name = "res.partner"
|
2012-05-07 11:54:32 +00:00
|
|
|
_inherit = ['res.partner', 'mail.thread']
|
2012-10-15 13:23:13 +00:00
|
|
|
_mail_flat_thread = False
|
2014-04-16 08:28:51 +00:00
|
|
|
_mail_mass_mailing = _('Customers')
|
2010-06-25 09:50:38 +00:00
|
|
|
|
2012-08-15 18:44:03 +00:00
|
|
|
_columns = {
|
2014-04-09 10:16:04 +00:00
|
|
|
'notify_email': fields.selection([
|
2013-03-13 11:17:46 +00:00
|
|
|
('none', 'Never'),
|
2013-12-18 13:18:05 +00:00
|
|
|
('always', 'All Messages'),
|
2014-04-17 09:41:33 +00:00
|
|
|
], 'Receive Inbox Notifications by Email', required=True,
|
|
|
|
oldname='notification_email_send',
|
2013-03-13 12:51:24 +00:00
|
|
|
help="Policy to receive emails for new messages pushed to your personal Inbox:\n"
|
|
|
|
"- Never: no emails are sent\n"
|
2013-03-13 11:17:46 +00:00
|
|
|
"- All Messages: for every notification you receive in your Inbox"),
|
2012-08-15 18:44:03 +00:00
|
|
|
}
|
2012-08-23 13:11:44 +00:00
|
|
|
|
2012-08-17 07:02:18 +00:00
|
|
|
_defaults = {
|
2014-04-09 10:16:04 +00:00
|
|
|
'notify_email': lambda *args: 'always'
|
2012-08-17 07:02:18 +00:00
|
|
|
}
|
2012-05-07 11:54:32 +00:00
|
|
|
|
2013-02-28 16:40:54 +00:00
|
|
|
def message_get_suggested_recipients(self, cr, uid, ids, context=None):
|
|
|
|
recipients = super(res_partner_mail, self).message_get_suggested_recipients(cr, uid, ids, context=context)
|
|
|
|
for partner in self.browse(cr, uid, ids, context=context):
|
2013-02-28 17:23:20 +00:00
|
|
|
self._message_add_suggested_recipient(cr, uid, recipients, partner, partner=partner, reason=_('Partner Profile'))
|
2013-02-28 16:40:54 +00:00
|
|
|
return recipients
|
|
|
|
|
2014-03-25 13:53:47 +00:00
|
|
|
def message_get_default_recipients(self, cr, uid, ids, context=None):
|
|
|
|
return dict((id, {'partner_ids': [id], 'email_to': False, 'email_cc': False}) for id in ids)
|