1. The merge of the "email_template" module into the "mail" module. 2. The send action of the mass mailing has been moved from the frontend to a cron, because it was too slow to send over 10,000 mails (the user's browser was blocked for 15 - 20 minutes). Mass mailings have now their own process in the kanban view. 3. Mails sent from the mail form are sent immediatly instead of from the mail queue (for instance, when you go to sales > customers > list view > select 2 -3 customers > More > Partner Mass Mailing). 4. Users have now the choice from which mailing list they want to unsubscribe when they click on the unsubscribe link at the bottom of the mail. 5. Mass mailings inherit from their campaign UTMs and mass mailing campaigns are linked to an UTM campaign. 6. Many little improvements
75 lines
3.0 KiB
Python
75 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from urllib import urlencode
|
|
|
|
from openerp.addons.web import http
|
|
from openerp.addons.web.http import request
|
|
from openerp.tools.mail import html_sanitize
|
|
|
|
|
|
class WebsiteEmailDesigner(http.Controller):
|
|
|
|
@http.route('/website_mail/email_designer', type='http', auth="user", website=True)
|
|
def index(self, model, res_id, template_model=None, **kw):
|
|
if not model or not model in request.registry or not res_id:
|
|
return request.redirect('/')
|
|
model_fields = request.registry[model]._fields
|
|
if 'body' not in model_fields and 'body_html' not in model_fields or \
|
|
'email' not in model_fields and 'email_from' not in model_fields or \
|
|
'name' not in model_fields and 'subject' not in model_fields:
|
|
return request.redirect('/')
|
|
res_id = int(res_id)
|
|
obj_ids = request.registry[model].exists(request.cr, request.uid, [res_id], context=request.context)
|
|
if not obj_ids:
|
|
return request.redirect('/')
|
|
# try to find fields to display / edit -> as t-field is static, we have to limit
|
|
# the available fields to a given subset
|
|
email_from_field = 'email'
|
|
if 'email_from' in model_fields:
|
|
email_from_field = 'email_from'
|
|
subject_field = 'name'
|
|
if 'subject' in model_fields:
|
|
subject_field = 'subject'
|
|
body_field = 'body'
|
|
if 'body_html' in model_fields:
|
|
body_field = 'body_html'
|
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
record = request.registry[model].browse(cr, uid, res_id, context=context)
|
|
|
|
values = {
|
|
'record': record,
|
|
'templates': None,
|
|
'model': model,
|
|
'res_id': res_id,
|
|
'email_from_field': email_from_field,
|
|
'subject_field': subject_field,
|
|
'body_field': body_field,
|
|
}
|
|
|
|
if getattr(record, body_field):
|
|
values['mode'] = 'email_designer'
|
|
else:
|
|
if kw.get('enable_editor'):
|
|
kw.pop('enable_editor')
|
|
fragments = dict(model=model, res_id=res_id, **kw)
|
|
if template_model:
|
|
fragments['template_model'] = template_model
|
|
return request.redirect('/website_mail/email_designer?%s' % urlencode(fragments))
|
|
values['mode'] = 'email_template'
|
|
|
|
tmpl_obj = request.registry['mail.template']
|
|
if template_model:
|
|
tids = tmpl_obj.search(cr, uid, [('model', '=', template_model)], context=context)
|
|
else:
|
|
tids = tmpl_obj.search(cr, uid, [], context=context)
|
|
templates = tmpl_obj.browse(cr, uid, tids, context=context)
|
|
values['templates'] = templates
|
|
values['html_sanitize'] = html_sanitize
|
|
|
|
return request.website.render("website_mail.email_designer", values)
|
|
|
|
@http.route(['/website_mail/snippets'], type='json', auth="user", website=True)
|
|
def snippets(self):
|
|
return request.website._render('website_mail.email_designer_snippets')
|