diff options
| author | Keyur Gajjar <kga@odoo.com> | 2016-06-15 15:03:04 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-06-17 11:23:12 +0200 |
| commit | bbca13541053a3ac35ac2ec340b843205117468a (patch) | |
| tree | c8abe4782bdcfcb084b60068615da7204f99d95b /addons/mass_mailing/controllers/main.py | |
| parent | 1467689edf44e3392ea3b195008faec96a3c4d0e (diff) | |
[MIG] mass_mailing: code migration to new api
NB: A controller in website_mass_mailing has been migrated too. It's not a real issue
as this module will also be migrated in the days to come
Diffstat (limited to 'addons/mass_mailing/controllers/main.py')
| -rw-r--r-- | addons/mass_mailing/controllers/main.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index c43e8206765..40a8207648d 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. import werkzeug -from openerp import http, SUPERUSER_ID, _ -from openerp.http import request +from odoo import http +from odoo.http import request class MassMailController(http.Controller): @@ -21,14 +22,13 @@ class MassMailController(http.Controller): res_ids = contacts.ids else: res_ids = [res_id] - mailing.update_opt_out(mailing_id, email, res_ids, True) + mailing.update_opt_out(email, res_ids, True) return _('You have been unsubscribed successfully') @http.route('/mail/track/<int:mail_id>/blank.gif', type='http', auth='none') def track_mail_open(self, mail_id, **post): """ Email tracking. """ - mail_mail_stats = request.registry.get('mail.mail.statistics') - mail_mail_stats.set_opened(request.cr, SUPERUSER_ID, mail_mail_ids=[mail_id]) + request.env['mail.mail.statistics'].sudo().set_opened(mail_mail_ids=[mail_id]) response = werkzeug.wrappers.Response() response.mimetype = 'image/gif' response.data = 'R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='.decode('base64') @@ -37,11 +37,9 @@ class MassMailController(http.Controller): @http.route('/r/<string:code>/m/<int:stat_id>', type='http', auth="none") def full_url_redirect(self, code, stat_id, **post): - cr, uid, context = request.cr, request.uid, request.context - # don't assume geoip is set, it is part of the website module # which mass_mailing doesn't depend on country_code = request.session.get('geoip', False) and request.session.geoip.get('country_code', False) - request.registry['link.tracker.click'].add_click(cr, uid, code, request.httprequest.remote_addr, country_code, stat_id=stat_id, context=context) - return werkzeug.utils.redirect(request.registry['link.tracker'].get_url_from_code(cr, uid, code, context=context), 301) + request.env['link.tracker.click'].add_click(code, request.httprequest.remote_addr, country_code, stat_id=stat_id) + return werkzeug.utils.redirect(request.env['link.tracker'].get_url_from_code(code), 301) |
