[FIX] mass_mailing:
- fixed forgottent import of mail_thread in mass_mailing, to enable bounce and replied tracking - fixed replied computation in message_route_process, adding the original email in parameters - fixed form view of campaign, to add edit and dlete now that clicking on it redirects to the waves - added track field on mail_mail, to avoid creating too mush entries in mail.mail.statistics - fixed mass_mailign controller bzr revid: tde@openerp.com-20130916114706-b9zyhp0ha6mr9fzg
This commit is contained in:
parent
20f9f42ea9
commit
1d76129a22
|
@ -874,9 +874,9 @@ class mail_thread(osv.AbstractModel):
|
||||||
"No possible route found for incoming message from %s to %s (Message-Id %s:)." \
|
"No possible route found for incoming message from %s to %s (Message-Id %s:)." \
|
||||||
"Create an appropriate mail.alias or force the destination model." % (email_from, email_to, message_id)
|
"Create an appropriate mail.alias or force the destination model." % (email_from, email_to, message_id)
|
||||||
|
|
||||||
def message_route_process(self, cr, uid, msg, routes, context=None):
|
def message_route_process(self, cr, uid, message, message_dict, routes, context=None):
|
||||||
# postpone setting msg.partner_ids after message_post, to avoid double notifications
|
# postpone setting message_dict.partner_ids after message_post, to avoid double notifications
|
||||||
partner_ids = msg.pop('partner_ids', [])
|
partner_ids = message_dict.pop('partner_ids', [])
|
||||||
thread_id = False
|
thread_id = False
|
||||||
for model, thread_id, custom_values, user_id, alias in routes:
|
for model, thread_id, custom_values, user_id, alias in routes:
|
||||||
if self._name == 'mail.thread':
|
if self._name == 'mail.thread':
|
||||||
|
@ -885,22 +885,22 @@ class mail_thread(osv.AbstractModel):
|
||||||
model_pool = self.pool[model]
|
model_pool = self.pool[model]
|
||||||
assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \
|
assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \
|
||||||
"Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \
|
"Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \
|
||||||
(msg['message_id'], model)
|
(message_dict['message_id'], model)
|
||||||
|
|
||||||
# disabled subscriptions during message_new/update to avoid having the system user running the
|
# disabled subscriptions during message_new/update to avoid having the system user running the
|
||||||
# email gateway become a follower of all inbound messages
|
# email gateway become a follower of all inbound messages
|
||||||
nosub_ctx = dict(context, mail_create_nosubscribe=True, mail_create_nolog=True)
|
nosub_ctx = dict(context, mail_create_nosubscribe=True, mail_create_nolog=True)
|
||||||
if thread_id and hasattr(model_pool, 'message_update'):
|
if thread_id and hasattr(model_pool, 'message_update'):
|
||||||
model_pool.message_update(cr, user_id, [thread_id], msg, context=nosub_ctx)
|
model_pool.message_update(cr, user_id, [thread_id], message_dict, context=nosub_ctx)
|
||||||
else:
|
else:
|
||||||
thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=nosub_ctx)
|
thread_id = model_pool.message_new(cr, user_id, message_dict, custom_values, context=nosub_ctx)
|
||||||
else:
|
else:
|
||||||
assert thread_id == 0, "Posting a message without model should be with a null res_id, to create a private message."
|
assert thread_id == 0, "Posting a message without model should be with a null res_id, to create a private message."
|
||||||
model_pool = self.pool.get('mail.thread')
|
model_pool = self.pool.get('mail.thread')
|
||||||
if not hasattr(model_pool, 'message_post'):
|
if not hasattr(model_pool, 'message_post'):
|
||||||
context['thread_model'] = model
|
context['thread_model'] = model
|
||||||
model_pool = self.pool['mail.thread']
|
model_pool = self.pool['mail.thread']
|
||||||
new_msg_id = model_pool.message_post(cr, uid, [thread_id], context=context, subtype='mail.mt_comment', **msg)
|
new_msg_id = model_pool.message_post(cr, uid, [thread_id], context=context, subtype='mail.mt_comment', **message_dict)
|
||||||
|
|
||||||
if partner_ids:
|
if partner_ids:
|
||||||
# postponed after message_post, because this is an external message and we don't want to create
|
# postponed after message_post, because this is an external message and we don't want to create
|
||||||
|
@ -972,7 +972,7 @@ class mail_thread(osv.AbstractModel):
|
||||||
|
|
||||||
# find possible routes for the message
|
# find possible routes for the message
|
||||||
routes = self.message_route(cr, uid, msg_txt, msg, model, thread_id, custom_values, context=context)
|
routes = self.message_route(cr, uid, msg_txt, msg, model, thread_id, custom_values, context=context)
|
||||||
thread_id = self.message_route_process(cr, uid, msg, routes, context=context)
|
thread_id = self.message_route_process(cr, uid, msg_txt, msg, routes, context=context)
|
||||||
return thread_id
|
return thread_id
|
||||||
|
|
||||||
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
|
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
|
|
||||||
import mass_mailing
|
import mass_mailing
|
||||||
import mail_mail
|
import mail_mail
|
||||||
|
import mail_thread
|
||||||
import wizard
|
import wizard
|
||||||
import controllers
|
import controllers
|
||||||
|
|
|
@ -8,5 +8,5 @@ class MassMailController(http.Controller):
|
||||||
def track_mail_open(self, mail_id):
|
def track_mail_open(self, mail_id):
|
||||||
""" Email tracking. """
|
""" Email tracking. """
|
||||||
mail_mail_stats = request.registry.get('mail.mail.statistics')
|
mail_mail_stats = request.registry.get('mail.mail.statistics')
|
||||||
mail_mail_stats.set_opened(request.cr, request.uid, mail_ids=[mail_id])
|
mail_mail_stats.set_opened(request.cr, request.uid, mail_mail_ids=[mail_id])
|
||||||
return False
|
return "data:image/gif;base64,R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
|
||||||
|
|
|
@ -23,7 +23,7 @@ from urlparse import urljoin
|
||||||
|
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv, fields
|
||||||
|
|
||||||
|
|
||||||
class MailMail(osv.Model):
|
class MailMail(osv.Model):
|
||||||
|
@ -31,16 +31,25 @@ class MailMail(osv.Model):
|
||||||
_name = 'mail.mail'
|
_name = 'mail.mail'
|
||||||
_inherit = ['mail.mail']
|
_inherit = ['mail.mail']
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'track': fields.boolean('Use tracking'),
|
||||||
|
}
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'track': False,
|
||||||
|
}
|
||||||
|
|
||||||
def create(self, cr, uid, values, context=None):
|
def create(self, cr, uid, values, context=None):
|
||||||
""" Override mail_mail creation to create an entry in mail.mail.statistics """
|
""" Override mail_mail creation to create an entry in mail.mail.statistics """
|
||||||
# TDE note: should be after 'all values computed', to have values (FIXME after merging other branch holding create refactoring)
|
# TDE note: should be after 'all values computed', to have values (FIXME after merging other branch holding create refactoring)
|
||||||
mail_id = super(MailMail, self).create(cr, uid, values, context=context)
|
mail_id = super(MailMail, self).create(cr, uid, values, context=context)
|
||||||
message_id = self.browse(cr, SUPERUSER_ID, mail_id).message_id
|
mail = self.browse(cr, SUPERUSER_ID, mail_id)
|
||||||
self.pool['mail.mail.statistics'].create(
|
if mail.track:
|
||||||
cr, uid, {
|
self.pool['mail.mail.statistics'].create(
|
||||||
'mail_mail_id': mail_id,
|
cr, uid, {
|
||||||
'message_id': message_id,
|
'mail_mail_id': mail_id,
|
||||||
}, context=context)
|
'message_id': mail.message_id,
|
||||||
|
}, context=context)
|
||||||
return mail_id
|
return mail_id
|
||||||
|
|
||||||
def _get_tracking_url(self, cr, uid, mail, partner=None, context=None):
|
def _get_tracking_url(self, cr, uid, mail, partner=None, context=None):
|
||||||
|
@ -53,7 +62,8 @@ class MailMail(osv.Model):
|
||||||
body = super(MailMail, self).send_get_mail_body(cr, uid, mail, partner=partner, context=context)
|
body = super(MailMail, self).send_get_mail_body(cr, uid, mail, partner=partner, context=context)
|
||||||
|
|
||||||
# generate tracking URL
|
# generate tracking URL
|
||||||
tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)
|
if mail.track:
|
||||||
if tracking_url:
|
tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)
|
||||||
body = tools.append_content_to_html(body, tracking_url, plaintext=False, container_tag='div')
|
if tracking_url:
|
||||||
|
body = tools.append_content_to_html(body, tracking_url, plaintext=False, container_tag='div')
|
||||||
return body
|
return body
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
|
from openerp.addons.mail.mail_message import decode
|
||||||
from openerp.addons.mail.mail_thread import decode_header
|
from openerp.addons.mail.mail_thread import decode_header
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv
|
||||||
|
|
||||||
|
@ -76,7 +77,8 @@ class MailThread(osv.Model):
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
self.write(cr, uid, [obj.id], {'message_bounce': obj.message_bounce + 1}, context=context)
|
self.write(cr, uid, [obj.id], {'message_bounce': obj.message_bounce + 1}, context=context)
|
||||||
|
|
||||||
def message_route_process(self, cr, uid, msg, routes, context=None):
|
def message_route_process(self, cr, uid, message, message_dict, routes, context=None):
|
||||||
if msg.get('message_id'):
|
if message.get('References'):
|
||||||
self.pool['mail.mail.statistics'].set_replied(cr, uid, mail_message_ids=[msg.get('message_id')], context=context)
|
message_ids = [x.strip() for x in decode(message['References']).split()]
|
||||||
return super(MailThread, self).message_route_process(cr, uid, msg, routes, context=context)
|
self.pool['mail.mail.statistics'].set_replied(cr, uid, mail_message_ids=message_ids, context=context)
|
||||||
|
return super(MailThread, self).message_route_process(cr, uid, message, message_dict, routes, context=context)
|
||||||
|
|
|
@ -251,6 +251,12 @@
|
||||||
<div class="oe_dropdown_toggle oe_dropdown_kanban">
|
<div class="oe_dropdown_toggle oe_dropdown_kanban">
|
||||||
<span class="oe_e">i</span>
|
<span class="oe_e">i</span>
|
||||||
<ul class="oe_dropdown_menu">
|
<ul class="oe_dropdown_menu">
|
||||||
|
<t t-if="widget.view.is_action_enabled('edit')">
|
||||||
|
<li><a type="edit">Settings</a></li>
|
||||||
|
</t>
|
||||||
|
<t t-if="widget.view.is_action_enabled('delete')">
|
||||||
|
<li><a type="delete">Delete</a></li>
|
||||||
|
</t>
|
||||||
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
|
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,10 +37,10 @@ class MailComposeMessage(osv.TransientModel):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
|
def get_mail_values(self, cr, uid, wizard, res_ids, context=None):
|
||||||
""" Override method that generated the mail content by adding the mass
|
""" Override method that generated the mail content by adding the mass
|
||||||
mailing campaign, when doing pure email mass mailing. """
|
mailing campaign, when doing pure email mass mailing. """
|
||||||
res = super(MailComposeMessage, self).render_message_batch(cr, uid, wizard, res_ids, context=context)
|
res = super(MailComposeMessage, self).get_mail_values(cr, uid, wizard, res_ids, context=context)
|
||||||
if wizard.composition_mode == 'mass_mail' and wizard.mass_mailing_campaign_id: # TODO: which kind of mass mailing ?
|
if wizard.composition_mode == 'mass_mail' and wizard.mass_mailing_campaign_id: # TODO: which kind of mass mailing ?
|
||||||
current_date = fields.datetime.now()
|
current_date = fields.datetime.now()
|
||||||
mass_mailing_id = self.pool['mail.mass_mailing'].create(
|
mass_mailing_id = self.pool['mail.mass_mailing'].create(
|
||||||
|
@ -52,4 +52,6 @@ class MailComposeMessage(osv.TransientModel):
|
||||||
'template_id': wizard.template_id and wizard.template_id.id or False,
|
'template_id': wizard.template_id and wizard.template_id.id or False,
|
||||||
}, context=context)
|
}, context=context)
|
||||||
context['default_mass_mailing_id'] = mass_mailing_id
|
context['default_mass_mailing_id'] = mass_mailing_id
|
||||||
|
for res_id in res_ids:
|
||||||
|
res[res_id]['track'] = True
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue