summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-06-30 11:32:55 +0200
committerThibault Delavallée <tde@openerp.com>2014-06-30 11:32:55 +0200
commitba4454ccfb9fc2de2dca0f7cd753ddb453b5f2fe (patch)
treef2bb109fb60bb9d285e6526fe10734d6733e7714 /addons/mail
parent58ad25d0e3f002a630698bd7627657d27490b40e (diff)
parent2c45b7162ce8d067123c54fa7d191c54fd024739 (diff)
Merge pull request #830 from odoo-dev/saas-4-mailing-lists-imp-tde
[IMP] [BACKPORT] Mailing lists usability improvements: headers related t...
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/mail_followers.py4
-rw-r--r--addons/mail/mail_group.py13
-rw-r--r--addons/mail/mail_mail.py10
-rw-r--r--addons/mail/mail_thread.py10
4 files changed, 33 insertions, 4 deletions
diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py
index 0985b16f5ac..1e2c6c8d9e6 100644
--- a/addons/mail/mail_followers.py
+++ b/addons/mail/mail_followers.py
@@ -183,7 +183,7 @@ class mail_notification(osv.Model):
references = message.parent_id.message_id if message.parent_id else False
# create email values
- max_recipients = 100
+ max_recipients = 50
chunks = [email_pids[x:x + max_recipients] for x in xrange(0, len(email_pids), max_recipients)]
email_ids = []
for chunk in chunks:
@@ -195,7 +195,7 @@ class mail_notification(osv.Model):
'references': references,
}
email_ids.append(self.pool.get('mail.mail').create(cr, uid, mail_values, context=context))
- if force_send and len(chunks) < 6: # for more than 500 followers, use the queue system
+ if force_send and len(chunks) < 2: # for more than 50 followers, use the queue system
self.pool.get('mail.mail').send(cr, uid, email_ids, context=context)
return True
diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py
index 4ae47a96774..186787c121a 100644
--- a/addons/mail/mail_group.py
+++ b/addons/mail/mail_group.py
@@ -211,3 +211,16 @@ class mail_group(osv.Model):
return []
else:
return super(mail_group, self).get_suggested_thread(cr, uid, removed_suggested_threads, context)
+
+ def message_get_email_values(self, cr, uid, id, notif_mail=None, context=None):
+ res = super(mail_group, self).message_get_email_values(cr, uid, id, notif_mail=notif_mail, context=context)
+ group = self.browse(cr, uid, id, context=context)
+ res.update({
+ 'headers': {
+ 'Precedence': 'list',
+ }
+ })
+ if group.alias_domain:
+ res['headers']['List-Id'] = '%s.%s' % (group.alias_name, group.alias_domain)
+ res['headers']['List-Post'] = '<mailto:%s@%s>' % (group.alias_name, group.alias_domain)
+ return res
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index 65970265ce3..633b270b754 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -201,12 +201,15 @@ class mail_mail(osv.Model):
"""
body = self.send_get_mail_body(cr, uid, mail, partner=partner, context=context)
body_alternative = tools.html2plaintext(body)
- return {
+ res = {
'body': body,
'body_alternative': body_alternative,
'subject': self.send_get_mail_subject(cr, uid, mail, partner=partner, context=context),
'email_to': self.send_get_mail_to(cr, uid, mail, partner=partner, context=context),
}
+ if mail.model and mail.res_id and self.pool.get(mail.model) and hasattr(self.pool[mail.model], 'message_get_email_values'):
+ res.update(self.pool[mail.model].message_get_email_values(cr, uid, mail.res_id, mail, context=context))
+ return res
def send(self, cr, uid, ids, auto_commit=False, raise_exception=False, context=None):
""" Sends the selected emails immediately, ignoring their current
@@ -254,6 +257,9 @@ class mail_mail(osv.Model):
# build an RFC2822 email.message.Message object and send it without queuing
res = None
for email in email_list:
+ email_headers = dict(headers)
+ if email.get('headers'):
+ email_headers.update(email['headers'])
msg = ir_mail_server.build_email(
email_from=mail.email_from,
email_to=email.get('email_to'),
@@ -268,7 +274,7 @@ class mail_mail(osv.Model):
object_id=mail.res_id and ('%s-%s' % (mail.res_id, mail.model)),
subtype='html',
subtype_alternative='plain',
- headers=headers)
+ headers=email_headers)
res = ir_mail_server.send_email(cr, uid, msg,
mail_server_id=mail.mail_server_id.id,
context=context)
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index c9662f04567..3691d352252 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -690,6 +690,16 @@ class mail_thread(osv.AbstractModel):
if record.alias_domain and record.alias_name else False
for record in self.browse(cr, SUPERUSER_ID, ids, context=context)]
+ def message_get_email_values(self, cr, uid, id, notif_mail=None, context=None):
+ """ Temporary method to create custom notification email values for a given
+ model and document. This should be better to have a headers field on
+ the mail.mail model, computed when creating the notification email, but
+ this cannot be done in a stable version.
+
+ TDE FIXME: rethink this ulgy thing. """
+ res = dict()
+ return res
+
#------------------------------------------------------
# Mail gateway
#------------------------------------------------------