summaryrefslogtreecommitdiff
path: root/addons/link_tracker
diff options
context:
space:
mode:
authorqmo-odoo <qmo@odoo.com>2019-09-06 06:36:21 +0000
committerThibault Delavallée <tde@odoo.com>2019-09-20 14:19:36 +0000
commitecd93e663976a3ce88e1b2b891450656049f411f (patch)
treec3e5230467a91ea2597d086e716ad3b2fd20122d /addons/link_tracker
parent1692d1ff3ea561c70bcd992e71913ba018f149f4 (diff)
[IMP] link_tracker: add global click count on campaign
Having a global click ratio on the campaign was pointless considering the nature of the social.app and its posts. Therefore, we decided to have a global click count which gives a better idea of the popularity of the campaign itself. Task ID 2074813 (FP request UTM refactor) PR: #37185
Diffstat (limited to 'addons/link_tracker')
-rw-r--r--addons/link_tracker/models/utm.py15
-rw-r--r--addons/link_tracker/views/utm_campaign_views.xml9
2 files changed, 19 insertions, 5 deletions
diff --git a/addons/link_tracker/models/utm.py b/addons/link_tracker/models/utm.py
index 71c94ba4eb6..6d356ad7d5a 100644
--- a/addons/link_tracker/models/utm.py
+++ b/addons/link_tracker/models/utm.py
@@ -11,11 +11,22 @@ class UtmCampaign(models.Model):
items_total = fields.Integer(string="Number of items that are part of the campaign", compute="_compute_items_total")
clicked_total = fields.Integer(string="Number of items that are part of the campaign who generated a click", compute="_compute_items_total")
clicks_ratio = fields.Integer(string="Global Clicks Ratio for the campaign", compute="_compute_clicks_ratio")
+ click_count = fields.Integer(string="Number of clicks generated by the campaign", compute="_compute_clicks_count")
+
+ def _compute_clicks_count(self):
+ click_data = self.env['link.tracker.click'].read_group(
+ [('campaign_id', 'in', self.ids)],
+ ['campaign_id'], ['campaign_id'])
+
+ mapped_data = {datum['campaign_id'][0]: datum['campaign_id_count'] for datum in click_data}
+
+ for campaign in self:
+ campaign.click_count = mapped_data.get(campaign.id, 0)
def _compute_items_total(self):
"""Empty method that will be implemented by inheriting classes"""
- self.clicked_total = False
- self.items_total = False
+ self.clicked_total = 0
+ self.items_total = 0
@api.depends('items_total', 'clicked_total')
def _compute_clicks_ratio(self):
diff --git a/addons/link_tracker/views/utm_campaign_views.xml b/addons/link_tracker/views/utm_campaign_views.xml
index 2ff5c1c0398..e39c1ec1845 100644
--- a/addons/link_tracker/views/utm_campaign_views.xml
+++ b/addons/link_tracker/views/utm_campaign_views.xml
@@ -7,8 +7,8 @@
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<button name="%(link_tracker_action_campaign)d"
- type="action" class="oe_stat_button order-12">
- <field name="clicks_ratio" widget="percentpie" string="Clicks"/>
+ type="action" class="oe_stat_button order-12" icon="fa-mouse-pointer">
+ <field name="click_count" widget="statinfo" string="Clicks"/>
</button>
</xpath>
</field>
@@ -19,9 +19,12 @@
<field name="model">utm.campaign</field>
<field name="inherit_id" ref="utm.utm_campaign_view_kanban"/>
<field name="arch" type="xml">
+ <xpath expr="//field[@name='stage_id']" position="after">
+ <field name="click_count"/>
+ </xpath>
<xpath expr="//div[@id='utm_statistics']" position="inside">
<div class="d-flex justify-content-between align-items-center w-100 order-1 mb-1">
- <strong>Clicks</strong> <span><field name="clicks_ratio"/> %</span>
+ <strong>Clicks</strong> <span><t t-esc="record.click_count.raw_value"/></span>
</div>
</xpath>
</field>