summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2014-08-25 10:13:55 +0200
committerThibault Delavallée <tde@odoo.com>2014-08-25 10:13:55 +0200
commitb8ac2d1ed79f59fb7c60a4510231ae1bfddd23a5 (patch)
tree8bf1b25f38d2129c9a21c77fe84faa78d1a48e76
parent2b3b1c3230ac0aaa58a22664c278b910b1611191 (diff)
parentac9954d210af5dc4240618cd80227b223789ecab (diff)
Merge pull request #1776 from acsone/8.0-jne-mass_mailing-improvements
[FIX] Mass mailing: fixed statistics computation + summary graph tooltips (using ustr) + values of the mass mailing when creating it from the mail composer wizard. Courtesy of Acsone.
-rw-r--r--addons/mass_mailing/models/mass_mailing.py10
-rw-r--r--addons/mass_mailing/wizard/mail_compose_message.py8
2 files changed, 12 insertions, 6 deletions
diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py
index b80aa43b088..17731500d3c 100644
--- a/addons/mass_mailing/models/mass_mailing.py
+++ b/addons/mass_mailing/models/mass_mailing.py
@@ -9,6 +9,7 @@ from openerp import tools
from openerp.exceptions import Warning
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools.translate import _
+from openerp.tools import ustr
from openerp.osv import osv, fields
@@ -271,7 +272,7 @@ class MassMailing(osv.Model):
"""
date_begin = date_begin.date()
section_result = [{'value': 0,
- 'tooltip': (date_begin + relativedelta.relativedelta(days=i)).strftime('%d %B %Y'),
+ 'tooltip': ustr((date_begin + relativedelta.relativedelta(days=i)).strftime('%d %B %Y')),
} for i in range(0, self._period_number)]
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
field_col_info = obj._all_columns.get(groupby_field.split(':')[0])
@@ -302,7 +303,7 @@ class MassMailing(osv.Model):
return res
def _get_statistics(self, cr, uid, ids, name, arg, context=None):
- """ Compute statistics of the mass mailing campaign """
+ """ Compute statistics of the mass mailing """
results = {}
cr.execute("""
SELECT
@@ -311,9 +312,9 @@ class MassMailing(osv.Model):
COUNT(CASE WHEN s.sent is not null THEN 1 ELSE null END) AS sent,
COUNT(CASE WHEN s.scheduled is not null AND s.sent is null AND s.exception is null THEN 1 ELSE null END) AS scheduled,
COUNT(CASE WHEN s.scheduled is not null AND s.sent is null AND s.exception is not null THEN 1 ELSE null END) AS failed,
- COUNT(CASE WHEN s.id is not null AND s.bounced is null THEN 1 ELSE null END) AS delivered,
+ COUNT(CASE WHEN s.sent is not null AND s.bounced is null THEN 1 ELSE null END) AS delivered,
COUNT(CASE WHEN s.opened is not null THEN 1 ELSE null END) AS opened,
- COUNT(CASE WHEN s.replied is not null THEN 1 ELSE null END) AS replied ,
+ COUNT(CASE WHEN s.replied is not null THEN 1 ELSE null END) AS replied,
COUNT(CASE WHEN s.bounced is not null THEN 1 ELSE null END) AS bounced
FROM
mail_mail_statistics s
@@ -328,7 +329,6 @@ class MassMailing(osv.Model):
for row in cr.dictfetchall():
results[row.pop('mailing_id')] = row
total = row['total'] or 1
- row['delivered'] = row['sent'] - row['bounced']
row['received_ratio'] = 100.0 * row['delivered'] / total
row['opened_ratio'] = 100.0 * row['opened'] / total
row['replied_ratio'] = 100.0 * row['replied'] / total
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index ede3fe37803..5f9bcc2deac 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -32,13 +32,19 @@ class MailComposeMessage(osv.TransientModel):
wizard.model in [item[0] for item in self.pool['mail.mass_mailing']._get_mailing_model(cr, uid, context=context)]:
mass_mailing = wizard.mass_mailing_id
if not mass_mailing:
+ reply_to_mode = wizard.no_auto_thread and 'email' or 'thread'
+ reply_to = wizard.no_auto_thread and wizard.reply_to or False
mass_mailing_id = self.pool['mail.mass_mailing'].create(
cr, uid, {
'mass_mailing_campaign_id': wizard.mass_mailing_campaign_id and wizard.mass_mailing_campaign_id.id or False,
'name': wizard.mass_mailing_name,
'template_id': wizard.template_id and wizard.template_id.id or False,
'state': 'done',
- 'mailing_type': wizard.model,
+ 'reply_to_mode': reply_to_mode,
+ 'reply_to': reply_to,
+ 'sent_date': fields.datetime.now(),
+ 'body_html': wizard.body,
+ 'mailing_model': wizard.model,
'mailing_domain': wizard.active_domain,
}, context=context)
mass_mailing = self.pool['mail.mass_mailing'].browse(cr, uid, mass_mailing_id, context=context)