Skip to content

Commit

Permalink
Merge pull request odoo#1776 from acsone/8.0-jne-mass_mailing-improve…
Browse files Browse the repository at this point in the history
…ments

[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.
  • Loading branch information
tde-banana-odoo committed Aug 25, 2014
2 parents 2b3b1c3 + ac9954d commit b8ac2d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions addons/mass_mailing/models/mass_mailing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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


Expand Down Expand Up @@ -271,7 +272,7 @@ def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, group
"""
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])
Expand Down Expand Up @@ -302,7 +303,7 @@ def _get_daily_statistics(self, cr, uid, ids, field_name, arg, context=None):
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
Expand All @@ -311,9 +312,9 @@ def _get_statistics(self, cr, uid, ids, name, arg, context=None):
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
Expand All @@ -328,7 +329,6 @@ def _get_statistics(self, cr, uid, ids, name, arg, context=None):
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
Expand Down
8 changes: 7 additions & 1 deletion addons/mass_mailing/wizard/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ def get_mail_values(self, cr, uid, wizard, res_ids, context=None):
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)
Expand Down

0 comments on commit b8ac2d1

Please sign in to comment.