diff options
| author | Jeremy Kersten <jke@odoo.com> | 2014-08-01 11:25:41 +0200 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2014-08-01 11:25:41 +0200 |
| commit | cc9205d1d1a75b10452d9f339ea7ad47103bdb9e (patch) | |
| tree | 1387c2a9ab584d54dce56cca39fcab91a0f9bf94 | |
| parent | a9bce700dc5f566df69e393c9e0ab4641e5ee0c3 (diff) | |
[FIX] mass_mailing: allow to add a user/email to a specific mailing list and not always the last as previously.
| -rw-r--r-- | addons/mass_mailing/controllers/main.py | 2 | ||||
| -rw-r--r-- | addons/mass_mailing/models/mass_mailing.py | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index 935b51c612c..666a7bb46e4 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -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 diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index eafab5272bd..c2d75880065 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -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): |
