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 @@
@@ -19,9 +19,12 @@
utm.campaign
+
+
+