diff options
Diffstat (limited to 'addons/mail/models/res_users.py')
| -rw-r--r-- | addons/mail/models/res_users.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index 2068e66c834..0d6ea26579c 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -75,16 +75,19 @@ class Users(models.Model): def activity_user_count(self): query = """SELECT m.id, count(*), act.res_model as model, CASE - WHEN now()::date - act.date_deadline::date = 0 Then 'today' - WHEN now()::date - act.date_deadline::date > 0 Then 'overdue' - WHEN now()::date - act.date_deadline::date < 0 Then 'planned' + WHEN %(today)s::date - act.date_deadline::date = 0 Then 'today' + WHEN %(today)s::date - act.date_deadline::date > 0 Then 'overdue' + WHEN %(today)s::date - act.date_deadline::date < 0 Then 'planned' END AS states FROM mail_activity AS act JOIN ir_model AS m ON act.res_model_id = m.id - WHERE user_id = %s + WHERE user_id = %(user_id)s GROUP BY m.id, states, act.res_model; """ - self.env.cr.execute(query, [self.env.uid]) + self.env.cr.execute(query, { + 'today': fields.Date.context_today(self), + 'user_id': self.env.uid, + }) activity_data = self.env.cr.dictfetchall() model_ids = [a['id'] for a in activity_data] model_names = {n[0]: n[1] for n in self.env['ir.model'].browse(model_ids).name_get()} |
