From c591e4e6c11cb18c64d74bd81dd5d7445e468f6d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 15 Jan 2018 16:00:54 +0100 Subject: [PATCH] [FIX] mail: translate model names In the activities, the name of the models were not translated This is only the server side of the fix. The context needs to be added in the JS call in another commit opw-805431 --- addons/mail/models/res_users.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index 5b3ce35f48f..c5b2d9bbec8 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -125,7 +125,7 @@ class Users(models.Model): @api.model def activity_user_count(self): - query = """SELECT m.name, count(*), act.res_model as model, + 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' @@ -134,16 +134,18 @@ class Users(models.Model): FROM mail_activity AS act JOIN ir_model AS m ON act.res_model_id = m.id WHERE user_id = %s - GROUP BY m.name, states, act.res_model; + GROUP BY m.id, states, act.res_model; """ self.env.cr.execute(query, [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()} user_activities = {} for activity in activity_data: if not user_activities.get(activity['model']): user_activities[activity['model']] = { - 'name': activity['name'], + 'name': model_names[activity['id']], 'model': activity['model'], 'icon': modules.module.get_module_icon(self.env[activity['model']]._original_module), 'total_count': 0, 'today_count': 0, 'overdue_count': 0, 'planned_count': 0,