[FIX] mail: fixed get_default_recipient, trying to call a method even if the target model do not have it; also fixed default recipients generation on the contact model; sending a mass mailing when not having recipient now raise a warning.
This commit is contained in:
parent
a26a0e6d30
commit
c93d169fde
|
@ -662,9 +662,10 @@ class mail_thread(osv.AbstractModel):
|
|||
|
||||
def message_get_default_recipients(self, cr, uid, ids, context=None):
|
||||
if context and context.get('thread_model') and context['thread_model'] in self.pool and context['thread_model'] != self._name:
|
||||
sub_ctx = dict(context)
|
||||
sub_ctx.pop('thread_model')
|
||||
return self.pool[context['thread_model']].message_get_default_recipients(cr, uid, ids, context=sub_ctx)
|
||||
if hasattr(self.pool[context['thread_model']], 'message_get_default_recipients'):
|
||||
sub_ctx = dict(context)
|
||||
sub_ctx.pop('thread_model')
|
||||
return self.pool[context['thread_model']].message_get_default_recipients(cr, uid, ids, context=sub_ctx)
|
||||
res = {}
|
||||
for record in self.browse(cr, SUPERUSER_ID, ids, context=context):
|
||||
recipient_ids, email_to, email_cc = set(), False, False
|
||||
|
|
|
@ -4,10 +4,9 @@ from datetime import datetime
|
|||
from dateutil import relativedelta
|
||||
import json
|
||||
import random
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
from openerp import tools
|
||||
from openerp.exceptions import Warning
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv import osv, fields
|
||||
|
@ -62,6 +61,12 @@ class MassMailingContact(osv.Model):
|
|||
rec_id = self.create(cr, uid, {'name': name, 'email': email}, context=context)
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
|
||||
def message_get_default_recipients(self, cr, uid, ids, context=None):
|
||||
res = {}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
res[record.id] = {'partner_ids': [], 'email_to': record.email, 'email_cc': False}
|
||||
return res
|
||||
|
||||
|
||||
class MassMailingList(osv.Model):
|
||||
"""Model of a contact list. """
|
||||
|
@ -549,6 +554,8 @@ class MassMailing(osv.Model):
|
|||
for mailing in self.browse(cr, uid, ids, context=context):
|
||||
# instantiate an email composer + send emails
|
||||
res_ids = self.get_recipients(cr, uid, mailing, context=context)
|
||||
if not res_ids:
|
||||
raise Warning('Please select recipients.')
|
||||
comp_ctx = dict(context, active_ids=res_ids)
|
||||
composer_values = {
|
||||
'author_id': author_id,
|
||||
|
|
Loading…
Reference in New Issue