summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-10-18 15:17:41 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-22 14:44:39 +0000
commit6f0d36fa67c91d0bd70cf092bd1d41c615e1e8be (patch)
tree8f92e2db08d551021a2003908dc111b4411d67c9
parente85faf398659a5beb0b1570a06af64dcf78dc1c8 (diff)
[REF] gamification : rename stat_* fields into granted_* to ease understanding
In this commit we rename stat_count into granted_count, and stat_count_distinct into granted_users_count to reflect more what are those variables, aka count of granted badges. Task ID: 1961053 PR #32594
-rw-r--r--addons/gamification/models/badge.py16
-rw-r--r--addons/gamification/views/badge.xml10
-rw-r--r--addons/hr_gamification/views/gamification_views.xml2
-rw-r--r--addons/website_profile/controllers/main.py2
-rw-r--r--addons/website_profile/views/website_profile.xml2
5 files changed, 16 insertions, 16 deletions
diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py
index bd270113a52..7bfdd074644 100644
--- a/addons/gamification/models/badge.py
+++ b/addons/gamification/models/badge.py
@@ -107,8 +107,8 @@ class GamificationBadge(models.Model):
'gamification.badge.user', 'badge_id',
string='Owners', help='The list of instances of this badge granted to users')
- stat_count = fields.Integer("Total", compute='_get_owners_info', help="The number of time this badge has been received.")
- stat_count_distinct = fields.Integer("Number of users", compute='_get_owners_info', help="The number of time this badge has been received by unique users.")
+ granted_count = fields.Integer("Total", compute='_get_owners_info', help="The number of time this badge has been received.")
+ granted_users_count = fields.Integer("Number of users", compute='_get_owners_info', help="The number of time this badge has been received by unique users.")
unique_owner_ids = fields.Many2many(
'res.users', string="Unique Owners", compute='_get_owners_info',
help="The list of unique users having received this badge.")
@@ -139,8 +139,8 @@ class GamificationBadge(models.Model):
the total number of users this badge was granted to
"""
self.env.cr.execute("""
- SELECT badge_id, count(user_id) as stat_count,
- count(distinct(user_id)) as stat_count_distinct,
+ SELECT badge_id, count(user_id) as granted_count,
+ count(distinct(user_id)) as granted_users_count,
array_agg(distinct(user_id)) as unique_owner_ids
FROM gamification_badge_user
WHERE badge_id in %s
@@ -148,14 +148,14 @@ class GamificationBadge(models.Model):
""", [tuple(self.ids)])
defaults = {
- 'stat_count': 0,
- 'stat_count_distinct': 0,
+ 'granted_count': 0,
+ 'granted_users_count': 0,
'unique_owner_ids': [],
}
mapping = {
badge_id: {
- 'stat_count': count,
- 'stat_count_distinct': distinct_count,
+ 'granted_count': count,
+ 'granted_users_count': distinct_count,
'unique_owner_ids': owner_ids,
}
for (badge_id, count, distinct_count, owner_ids) in self.env.cr._obj
diff --git a/addons/gamification/views/badge.xml b/addons/gamification/views/badge.xml
index 5dc93d1f921..1115729191f 100644
--- a/addons/gamification/views/badge.xml
+++ b/addons/gamification/views/badge.xml
@@ -35,7 +35,7 @@
<field name="arch" type="xml">
<tree string="Badge List">
<field name="name"/>
- <field name="stat_count"/>
+ <field name="granted_count"/>
<field name="stat_this_month"/>
<field name="stat_my"/>
<field name="rule_auth"/>
@@ -93,9 +93,9 @@
</group>
<group string="Statistics">
<group>
- <field name="stat_count"/>
+ <field name="granted_count"/>
<field name="stat_this_month"/>
- <field name="stat_count_distinct"/>
+ <field name="granted_users_count"/>
</group>
<group>
<field name="stat_my"/>
@@ -117,7 +117,7 @@
<field name="name"/>
<field name="description"/>
<field name="stat_my"/>
- <field name="stat_count"/>
+ <field name="granted_count"/>
<field name="stat_this_month"/>
<field name="unique_owner_ids"/>
<field name="stat_my_monthly_sending"/>
@@ -141,7 +141,7 @@
</span>
<div t-if="record.remaining_sending.value == 0" class="oe_grey">Can not grant</div>
<div>
- <strong><t t-esc="record.stat_count.raw_value"/></strong> granted,
+ <strong><t t-esc="record.granted_count.raw_value"/></strong> granted,
<strong><t t-esc="record.stat_this_month.raw_value"/></strong> this month
</div>
<div t-if="record.description.value" class="o_kanban_badge_description">
diff --git a/addons/hr_gamification/views/gamification_views.xml b/addons/hr_gamification/views/gamification_views.xml
index 6eddd1171ca..3ce94e91a14 100644
--- a/addons/hr_gamification/views/gamification_views.xml
+++ b/addons/hr_gamification/views/gamification_views.xml
@@ -7,7 +7,7 @@
<field name="inherit_id" ref="gamification.badge_form_view"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
- <button class="oe_stat_button" type="object" name="get_granted_employees" attrs="{'invisible': [('stat_count','=',0)]}" icon="fa-user">
+ <button class="oe_stat_button" type="object" name="get_granted_employees" attrs="{'invisible': [('granted_count','=',0)]}" icon="fa-user">
<field name="granted_employees_count" string="Granted" widget="statinfo"/>
</button>
</div>
diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py
index 2148f5b78a2..858efd34f16 100644
--- a/addons/website_profile/controllers/main.py
+++ b/addons/website_profile/controllers/main.py
@@ -180,7 +180,7 @@ class WebsiteProfile(http.Controller):
Badge = request.env['gamification.badge']
badges = Badge.sudo().search(self._prepare_badges_domain(**kwargs))
- badges = sorted(badges, key=lambda b: b.stat_count_distinct, reverse=True)
+ badges = sorted(badges, key=lambda b: b.granted_users_count, reverse=True)
values = self._prepare_user_values(searches={'badges': True})
values.update({
diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml
index 881bcb7f0da..1b3c85ea599 100644
--- a/addons/website_profile/views/website_profile.xml
+++ b/addons/website_profile/views/website_profile.xml
@@ -442,7 +442,7 @@
<h6 t-field="badge.name" class="d-inline my-0"/>
</td>
<td class="align-middle d-none d-md-table-cell">
- <b t-esc="badge.stat_count_distinct"/>
+ <b t-esc="badge.granted_users_count"/>
<i class="text-muted"> awarded users</i>
</td>
<td class="align-middle">