Skip to content
Browse files

[FIX] mail: activity document name=>updated name

The activities "Document Name" (res_name) are computed and stored by
getting them on original document, so if we change name of original
model => the activity names are not updated.

Thus the document name we see we showing the "Activity" view is the one
that was used when activities were created with an odd heuristic (by
inverse order of activity type and max alphabetical value) and not

With this changeset we ignore "Document Name" and directly get names of
records when display "Activity" view.

note: the changeset also filter out activities on document we can reads:
this was done when a domain was set but not otherwise so access error
could be easily gotten.

closes #31850
  • Loading branch information...
nle-odoo committed Mar 14, 2019
1 parent c68a97a commit 38b6e04b9737a55655da5ebd804972464f4eb244
Showing with 7 additions and 4 deletions.
  1. +7 −4 addons/mail/models/
@@ -434,19 +434,21 @@ def get_activity_data(self, res_model, domain):
activity_domain.append(('res_id', 'in', res.ids))
grouped_activities = self.env['mail.activity'].read_group(
['res_id', 'activity_type_id', 'res_name:max(res_name)', 'ids:array_agg(id)', 'date_deadline:min(date_deadline)'],
['res_id', 'activity_type_id', 'ids:array_agg(id)', 'date_deadline:min(date_deadline)'],
['res_id', 'activity_type_id'],
# filter out unreadable records
if not domain:
res_ids = tuple(a['res_id'] for a in grouped_activities)
res = self.env[res_model].search([('id', 'in', res_ids)])
grouped_activities = [a for a in grouped_activities if a['res_id'] in res.ids]
activity_type_ids = self.env['mail.activity.type']
res_id_to_name = {}
res_id_to_deadline = {}
activity_data = defaultdict(dict)
for group in grouped_activities:
res_id = group['res_id']
res_name = group['res_name']
activity_type_id = group['activity_type_id'][0]
activity_type_ids |= self.env['mail.activity.type'].browse(activity_type_id) # we will get the name when reading mail_template_ids
res_id_to_name[res_id] = res_name
res_id_to_deadline[res_id] = group['date_deadline'] if (res_id not in res_id_to_deadline or group['date_deadline'] < res_id_to_deadline[res_id]) else res_id_to_deadline[res_id]
state = self._compute_state_from_date(group['date_deadline'], self.user_id.sudo().tz)
activity_data[res_id][activity_type_id] = {
@@ -456,6 +458,7 @@ def get_activity_data(self, res_model, domain):
'o_closest_deadline': group['date_deadline'],
res_ids_sorted = sorted(res_id_to_deadline, key=lambda item: res_id_to_deadline[item])
res_id_to_name = dict(self.env[res_model].browse(res_ids_sorted).name_get())
activity_type_infos = []
for elem in sorted(activity_type_ids, key=lambda item: item.sequence):
mail_template_info = []

0 comments on commit 38b6e04

Please sign in to comment.
You can’t perform that action at this time.