[IMP] mass_mailing(_sms): "Click" stat button now redirects to link trackers

PURPOSE

Clarify the use case in which a specified email address is set as replies may
not be traceable. Make the %Click KPIs visible for Emails as well. Allow users
to report on the links that have (or not) been clicked from their
mailing.

SPECIFICATIONS

Display list of link trackers linked to the mailing on 'click' stat button
click.

Task ID: 2202495
PR #48339

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Sébastien Mottet (oms)
2020-05-27 11:00:29 +00:00
committed by Thibault Delavallée
parent 60e4e9912a
commit fd87ff4843
3 changed files with 15 additions and 6 deletions
@@ -22,6 +22,7 @@ class LinkTracker(models.Model):
_name = "link.tracker"
_rec_name = "short_url"
_description = "Link Tracker"
_order="count DESC"
_inherit = ["utm.mixin"]
# URL info
@@ -62,7 +62,7 @@
<field name="url"/>
<field name="short_url" optional="hide"/>
<field name="count"/>
<button name="action_visit_page" type="object" string="Visit Page" icon="fa-external-link"/>
<button name="action_visit_page" type="object" string="Visit Page" icon="fa-external-link"/>
</tree>
</field>
</record>
+13 -5
View File
@@ -72,7 +72,6 @@ class MassMailing(models.Model):
'utm.medium', string='Medium',
compute='_compute_medium_id', readonly=False, store=True,
help="UTM Medium: delivery method (email, sms, ...)")
clicks_ratio = fields.Integer(compute="_compute_clicks_ratio", string="Number of Clicks")
state = fields.Selection([('draft', 'Draft'), ('in_queue', 'In Queue'), ('sending', 'Sending'), ('done', 'Sent')],
string='Status', required=True, tracking=True, copy=False, default='draft', group_expand='_group_expand_states')
color = fields.Integer(string='Color Index')
@@ -126,6 +125,7 @@ class MassMailing(models.Model):
opened_ratio = fields.Integer(compute="_compute_statistics", string='Opened Ratio')
replied_ratio = fields.Integer(compute="_compute_statistics", string='Replied Ratio')
bounced_ratio = fields.Integer(compute="_compute_statistics", string='Bounced Ratio')
clicks_ratio = fields.Integer(compute="_compute_clicks_ratio", string="Number of Clicks")
next_departure = fields.Datetime(compute="_compute_next_departure", string='Scheduled date')
def _compute_total(self):
@@ -326,6 +326,17 @@ class MassMailing(models.Model):
action['context'][filter_key] = True
return action
def action_view_clicked(self):
model_name = self.env['ir.model']._get('link.tracker').display_name
return {
'name': model_name,
'type': 'ir.actions.act_window',
'view_mode': 'tree',
'res_model': 'link.tracker',
'domain': [('mass_mailing_id.id', '=', self.id)],
'context': dict(self._context, create=False)
}
def action_view_opened(self):
return self._action_view_documents_filtered('opened')
@@ -335,14 +346,11 @@ class MassMailing(models.Model):
def action_view_bounced(self):
return self._action_view_documents_filtered('bounced')
def action_view_clicked(self):
return self._action_view_documents_filtered('clicked')
def action_view_delivered(self):
return self._action_view_documents_filtered('delivered')
def _action_view_documents_filtered(self, view_filter):
if view_filter in ('opened', 'replied', 'bounced', 'clicked'):
if view_filter in ('opened', 'replied', 'bounced'):
opened_stats = self.mailing_trace_ids.filtered(lambda stat: stat[view_filter])
elif view_filter == ('delivered'):
opened_stats = self.mailing_trace_ids.filtered(lambda stat: stat.sent and not stat.bounced)