[IMP] mass_mailing: Display the number of clicks on reporting

Purpose
=======

On the pivot table for reporting on mass mailing you have all the options on the individual mass mailing, except clicks.
This stat is however available in mass mail form

Secification
============

Add 'Clicks' in pivot table reporting view
This commit is contained in:
Kirti Choudhary
2018-02-06 06:36:05 +01:00
committed by Yannick Tivisse
parent 3b8ba47f11
commit bacc043fb5
3 changed files with 6 additions and 0 deletions
@@ -414,6 +414,7 @@ class MassMailing(models.Model):
sent = fields.Integer(compute="_compute_statistics")
delivered = fields.Integer(compute="_compute_statistics")
opened = fields.Integer(compute="_compute_statistics")
clicked = fields.Integer(compute="_compute_statistics")
replied = fields.Integer(compute="_compute_statistics")
bounced = fields.Integer(compute="_compute_statistics")
failed = fields.Integer(compute="_compute_statistics")
@@ -457,6 +458,7 @@ class MassMailing(models.Model):
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.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.clicked is not null THEN 1 ELSE null END) AS clicked,
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,
COUNT(CASE WHEN s.exception is not null THEN 1 ELSE null END) AS failed
@@ -474,6 +476,7 @@ class MassMailing(models.Model):
total = row.pop('total') or 1
row['received_ratio'] = 100.0 * row['delivered'] / total
row['opened_ratio'] = 100.0 * row['opened'] / total
row['clicks_ratio'] = 100.0 * row['clicked'] / total
row['replied_ratio'] = 100.0 * row['replied'] / total
row['bounced_ratio'] = 100.0 * row['bounced'] / total
self.browse(row.pop('mailing_id')).update(row)
@@ -17,6 +17,7 @@ class MassMailingReport(models.Model):
opened = fields.Integer(readonly=True)
bounced = fields.Integer(readonly=True)
replied = fields.Integer(readonly=True)
clicked = fields.Integer(readonly=True)
state = fields.Selection([('draft', 'Draft'), ('test', 'Tested'), ('done', 'Sent')],
string='Status', readonly=True)
email_from = fields.Char('From', readonly=True)
@@ -39,6 +40,7 @@ class MassMailingReport(models.Model):
(count(ms.sent) - count(ms.bounced)) as delivered,
count(ms.opened) as opened,
count(ms.replied) as replied,
count(ms.clicked) as clicked,
mm.state,
mm.email_from
FROM
@@ -11,6 +11,7 @@
<field name="opened" type="measure"/>
<field name="bounced" type="measure"/>
<field name="replied" type="measure"/>
<field name="clicked" type="measure"/>
</pivot>
</field>
</record>