diff options
| author | Olivier Dony <odo@openerp.com> | 2014-08-01 13:06:49 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2014-08-01 13:06:49 +0200 |
| commit | ee4df1e397a7f1ada09f53c3b72d9dddfa9b3e22 (patch) | |
| tree | 438b018b377a0c94be1d19e4c3928974b9d18f08 /addons/mass_mailing | |
| parent | 5ddc0305cd0bef77632ee50fb19ae7372ae5cb68 (diff) | |
| parent | 8b15482e0037b2484e993ffaf9e5691662c99e28 (diff) | |
[MERGE] Forward-port saas-4 up to 8b15482
Diffstat (limited to 'addons/mass_mailing')
| -rw-r--r-- | addons/mass_mailing/controllers/main.py | 3 | ||||
| -rw-r--r-- | addons/mass_mailing/models/mass_mailing.py | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index 5eed0e38615..bfe975059c5 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -67,8 +67,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: - contact_ng = Contacts.name_create(cr, SUPERUSER_ID, email, context=context) - Contacts.write(cr, SUPERUSER_ID, [contact_ng[0]], {'list_id': int(list_id)}, 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 a1077a3fffa..001a15b2891 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): |
