Skip to content

Commit

Permalink
[FIX] mail: translate model names
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mart-e committed Jan 15, 2018
1 parent 1d9c3a0 commit c591e4e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions addons/mail/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def message_get_suggested_recipients(self):

@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'
Expand All @@ -134,16 +134,18 @@ def activity_user_count(self):
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,
Expand Down

0 comments on commit c591e4e

Please sign in to comment.