[FIX] mass_mailing: allow to add a user/email to a specific mailing list and not always the last as previously.
This commit is contained in:
parent
a9bce700dc
commit
cc9205d1d1
|
@ -68,7 +68,7 @@ class MassMailController(http.Controller):
|
|||
|
||||
contact_ids = Contacts.search(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], context=context)
|
||||
if not contact_ids:
|
||||
Contacts.name_create(cr, SUPERUSER_ID, email, context=context)
|
||||
Contacts.add_to_list(cr, SUPERUSER_ID, email, int(list_id), context=context)
|
||||
# add email to session
|
||||
request.session['mass_mailing_email'] = email
|
||||
return True
|
||||
|
|
|
@ -52,15 +52,24 @@ class MassMailingContact(osv.Model):
|
|||
'list_id': _get_latest_list
|
||||
}
|
||||
|
||||
def name_create(self, cr, uid, name, context=None):
|
||||
def get_name_email(self, name, context):
|
||||
name, email = self.pool['res.partner']._parse_partner_name(name, context=context)
|
||||
if name and not email:
|
||||
email = name
|
||||
if email and not name:
|
||||
name = email
|
||||
return name, email
|
||||
|
||||
def name_create(self, cr, uid, name, context=None):
|
||||
name, email = self.get_name_email(name, context=context)
|
||||
rec_id = self.create(cr, uid, {'name': name, 'email': email}, context=context)
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
|
||||
def add_to_list(self, cr, uid, name, list_id, context=None):
|
||||
name, email = self.get_name_email(name, context=context)
|
||||
rec_id = self.create(cr, uid, {'name': name, 'email': email, 'list_id': list_id}, 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):
|
||||
|
|
Loading…
Reference in New Issue