summaryrefslogtreecommitdiff
path: root/addons/gamification/models
diff options
context:
space:
mode:
authorChristophe Monniez <moc@odoo.com>2018-08-21 16:43:33 +0200
committerChristophe Monniez <moc@odoo.com>2018-08-22 09:28:16 +0200
commit3ff0948b0a7ce98048ced74fa6509b2720caa05d (patch)
treef25736e632579402a94612b3a1abfca9ee562752 /addons/gamification/models
parent0b2d6d748718c9ae6c1a850ea6eb91fa75ee96d7 (diff)
[FIX] gamification: compute badge stats wihtout error
Since 960360a, when computing badge stats, a datetime was compared to a string leading to a traceback. e.g. when clicking in employess > badges. Also, due to a typo, the compute method was assigning the stats result to the wrong attributes. e.g. 'stats_my_this_month' instead of 'stat_my_this_month'. With this commit, the above mentioned issues are fixed and a test is covering these issues to avoid regression.
Diffstat (limited to 'addons/gamification/models')
-rw-r--r--addons/gamification/models/badge.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py
index 3ca11577c33..6da94ddf9c1 100644
--- a/addons/gamification/models/badge.py
+++ b/addons/gamification/models/badge.py
@@ -157,18 +157,18 @@ class GamificationBadge(models.Model):
@api.depends('owner_ids.badge_id', 'owner_ids.create_date', 'owner_ids.user_id')
def _get_badge_user_stats(self):
"""Return stats related to badge users"""
- first_month_day = fields.Date.to_string(date.today().replace(day=1))
+ first_month_day = date.today().replace(day=1)
for badge in self:
owners = badge.owner_ids
- badge.stats_my = sum(o.user_id == self.env.user for o in owners)
- badge.stats_this_month = sum(o.create_date >= first_month_day for o in owners)
- badge.stats_my_this_month = sum(
- o.user_id == self.env.user and o.create_date >= first_month_day
+ badge.stat_my = sum(o.user_id == self.env.user for o in owners)
+ badge.stat_this_month = sum(o.create_date.date() >= first_month_day for o in owners)
+ badge.stat_my_this_month = sum(
+ o.user_id == self.env.user and o.create_date.date() >= first_month_day
for o in owners
)
- badge.stats_my_monthly_sending = sum(
- o.create_uid == self.env.user and o.create_date >= first_month_day
+ badge.stat_my_monthly_sending = sum(
+ o.create_uid == self.env.user and o.create_date.date() >= first_month_day
for o in owners
)