From e01e24aa9c4433772751a84f0e57eb1ffcdf1507 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Wed, 18 Nov 2015 12:27:53 +0100
Subject: [PATCH] [FIX] mail: chatter: subtype when tracking
When having a tracking, the subtype description should be displayed. This is
used for tracking linked to a subtype like Task Opened, Task Blocked, ...
This feature was forgotten when refactoring the chatter for v9 and is now
back.
---
addons/mail/models/mail_message.py | 11 ++++++-----
addons/mail/static/src/js/chat_manager.js | 1 +
addons/mail/static/src/xml/thread.xml | 3 +++
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py
index 6bd83f6427c..3ec357c8610 100644
--- a/addons/mail/models/mail_message.py
+++ b/addons/mail/models/mail_message.py
@@ -549,14 +549,15 @@ class Message(models.Model):
message_tree = dict((m.id, m) for m in self)
self._message_read_dict_postprocess(message_values, message_tree)
- # add is_note flag
- internal_subtype_ids = self.env['mail.message.subtype'].search([('internal', '=', True)]).ids
+ # add subtype data (is_note flag, subtype_description)
+ subtypes = self.env['mail.message.subtype'].search(
+ [('id', 'in', [msg['subtype_id'][0] for msg in message_values if msg['subtype_id']])]).read(['internal', 'description'])
+ subtypes_dict = dict((subtype['id'], subtype) for subtype in subtypes)
for message in message_values:
- if message['subtype_id'] and message['subtype_id'][0]:
- message['is_note'] = bool(message['subtype_id'][0] in internal_subtype_ids)
+ message['is_note'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['internal']
+ message['subtype_description'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['description']
return message_values
-
#------------------------------------------------------
# mail_message internals
#------------------------------------------------------
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js
index 6da02410141..56c9e6405d7 100644
--- a/addons/mail/static/src/js/chat_manager.js
+++ b/addons/mail/static/src/js/chat_manager.js
@@ -72,6 +72,7 @@ function make_message (data) {
body: data.body || "",
date: data.date,
message_type: data.message_type,
+ subtype_description: data.subtype_description,
is_note: data.is_note,
attachment_ids: data.attachment_ids,
subject: data.subject,
diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml
index b2b5fa088f1..62f692a9901 100644
--- a/addons/mail/static/src/xml/thread.xml
+++ b/addons/mail/static/src/xml/thread.xml
@@ -102,6 +102,9 @@
+
+
+
Subject: