Task: [mail] clean chatter.

Remove "always" tracking support
Change greay background logic
This commit is contained in:
Xavier-Do
2018-01-19 10:06:42 +01:00
parent 4a82e3d4c6
commit 935e4f6a25
9 changed files with 21 additions and 26 deletions
@@ -229,6 +229,7 @@ var LivechatButton = Widget.extend({
date: moment(time.str_to_datetime(data.date)),
is_needaction: false,
is_note: data.is_note,
is_discussion: data.is_discussion,
customer_email_data: []
};
+4 -2
View File
@@ -404,6 +404,7 @@ class Message(models.Model):
'id': 59,
'subject': False
'is_note': True # only if the subtype is internal
'is_discussion': False # only if the message is a discussion (subtype == discussion)
}
"""
message_values = self.read([
@@ -417,13 +418,14 @@ class Message(models.Model):
message_tree = dict((m.id, m) for m in self.sudo())
self._message_read_dict_postprocess(message_values, message_tree)
# add subtype data (is_note flag, subtype_description). Do it as sudo
# add subtype data (is_note flag, is_discussion flag , subtype_description). Do it as sudo
# because portal / public may have to look for internal subtypes
subtype_ids = [msg['subtype_id'][0] for msg in message_values if msg['subtype_id']]
subtypes = self.env['mail.message.subtype'].sudo().browse(subtype_ids).read(['internal', 'description'])
subtypes = self.env['mail.message.subtype'].sudo().browse(subtype_ids).read(['internal', 'description','id'])
subtypes_dict = dict((subtype['id'], subtype) for subtype in subtypes)
for message in message_values:
message['is_note'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['internal']
message['is_discussion'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment')
message['subtype_description'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['description']
if message['model'] and self.env[message['model']]._original_module:
message['module_icon'] = modules.module.get_module_icon(self.env[message['model']]._original_module)
+2 -15
View File
@@ -461,8 +461,7 @@ class MailThread(models.AbstractModel):
def _get_tracked_fields(self, updated_fields):
""" Return a structure of tracked fields for the current model.
:param list updated_fields: modified field names
:return dict: a dict mapping field name to description, containing
always tracked fields and modified on_change fields
:return dict: a dict mapping field name to description, containing on_change fields
"""
tracked_fields = []
for name, field in self._fields.items():
@@ -521,14 +520,11 @@ class MailThread(models.AbstractModel):
- a set of updated column names
- a list of changes (initial value, new value, column name, column info) """
self.ensure_one()
changes = set() # contains always and onchange tracked fields that changed
displays = set() # contains always tracked field that did not change but displayed for information
changes = set() # contains onchange tracked fields that changed
tracking_value_ids = []
display_values_ids = []
# generate tracked_values data structure: {'col_name': {col_info, new_value, old_value}}
for col_name, col_info in tracked_fields.items():
track_visibility = getattr(self._fields[col_name], 'track_visibility', 'onchange')
initial_value = initial[col_name]
new_value = getattr(self, col_name)
@@ -539,15 +535,6 @@ class MailThread(models.AbstractModel):
if col_name in tracked_fields:
changes.add(col_name)
# 'always' tracked fields in separate variable; added if other changes
elif new_value == initial_value and track_visibility == 'always' and col_name in tracked_fields:
tracking = self.env['mail.tracking.value'].create_tracking_values(initial_value, initial_value, col_name, col_info)
if tracking:
display_values_ids.append([0, 0, tracking])
displays.add(col_name)
if changes and displays:
tracking_value_ids = display_values_ids + tracking_value_ids
return changes, tracking_value_ids
@@ -130,6 +130,7 @@ function make_message (data) {
subtype_description: data.subtype_description,
is_author: data.author_id && data.author_id[0] === session.partner_id,
is_note: data.is_note,
is_discussion: data.is_discussion,
is_system_notification: (data.message_type === 'notification' && data.model === 'mail.channel')
|| data.info === 'transient_message',
attachment_ids: data.attachment_ids || [],
+1 -1
View File
@@ -109,7 +109,7 @@
text-align: justify;
}
&.o_mail_note {
&.o_mail_not_discussion {
background-color: @mail-thread-note;
padding-left: @grid-gutter-width*0.3;
border-bottom: 1px solid @gray-lighter-dark;
+1 -1
View File
@@ -160,7 +160,7 @@
t-att-class="'fa o_thread_message_star o_thread_icon ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
t-att-data-message-id="message.id" title="Mark as Todo"/>
</div>
<div t-att-class="'o_thread_message_core' + (message.is_note ? ' o_mail_note' : '')">
<div t-att-class="'o_thread_message_core' + (message.is_note ? ' o_mail_note' : '') + (message.is_discussion ? ' o_mail_discussion' : ' o_mail_not_discussion') + ' '+message.is_discussion">
<p t-if="message.display_author" class="o_mail_info">
<t t-if="message.is_note">
Note by
@@ -27,6 +27,7 @@ QUnit.module('mail', {}, function () {
displayed_author: "John Doe",
id: 1,
is_note: false,
is_discussion: true,
is_starred: false,
model: 'partner',
res_id: 2
@@ -418,6 +418,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
displayed_author: "John Doe",
id: 1,
is_note: false,
is_discussion: true,
is_starred: false,
model: 'partner',
res_id: 2,
@@ -467,6 +468,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
displayed_author: "Me",
id: msg_id,
is_note: event.data.message.subtype === 'mail.mt_note',
is_discussion: event.data.message.subtype === 'mail.mt_comment',
is_starred: false,
model: 'partner',
res_id: 2,
@@ -615,6 +617,7 @@ QUnit.test('chatter: post a message and switch in edit mode', function (assert)
displayed_author: "Me",
id: 42,
is_note: event.data.message.subtype === 'mail.mt_note',
is_discussion: event.data.message.subtype === 'mail.mt_comment',
is_starred: false,
model: 'partner',
res_id: 2,
@@ -686,6 +689,7 @@ QUnit.test('chatter: Attachment viewer', function (assert) {
displayed_author: "John Doe",
id: 1,
is_note: false,
is_discussion: true,
is_starred: false,
model: 'partner',
res_id: 2,
@@ -934,6 +938,7 @@ QUnit.test('form activity widget: mark as done and remove', function (assert) {
displayed_author: "John Doe",
id: 1,
is_note: true,
is_discussion: false,
});
route = '/web/dataset/call_kw/mail.activity/unlink';
args.method = 'unlink';
+5 -7
View File
@@ -40,7 +40,7 @@ class TestTracking(common.BaseFunctionalTest, common.MockEmails):
self.assertEqual(self.record.message_ids, self.env['mail.message'])
def test_message_track_no_subtype(self):
""" Update some tracked fields not linked to some subtype -> message with onchange + always tracked values """
""" Update some tracked fields not linked to some subtype -> message with onchange """
customer = self.env['res.partner'].create({'name': 'Customer', 'email': 'cust@example.com'})
self.record.write({
'name': 'Test2',
@@ -59,12 +59,11 @@ class TestTracking(common.BaseFunctionalTest, common.MockEmails):
# verify tracked value
self.assertTracking(
self.record.message_ids,
[('email_from', 'char', False, False), # always tracked field
('customer_id', 'many2one', False, customer) # onchange tracked field
[('customer_id', 'many2one', False, customer) # onchange tracked field
])
def test_message_track_subtype(self):
""" Update some tracked fields linked to some subtype -> message with onchange + always tracked values """
""" Update some tracked fields linked to some subtype -> message with onchange """
self.record.message_subscribe(
partner_ids=[self.user_admin.partner_id.id],
subtype_ids=[self.env.ref('test_mail.st_mail_test_full_umbrella_upd').id]
@@ -87,12 +86,11 @@ class TestTracking(common.BaseFunctionalTest, common.MockEmails):
# verify tracked value
self.assertTracking(
self.record.message_ids,
[('email_from', 'char', False, 'noone@example.com'), # always tracked field
('umbrella_id', 'many2one', False, umbrella) # onchange tracked field
[('umbrella_id', 'many2one', False, umbrella) # onchange tracked field
])
def test_message_track_template(self):
""" Update some tracked fields linked to some template -> message with onchange + always tracked values """
""" Update some tracked fields linked to some template -> message with onchange """
self.record.write({'mail_template': self.env.ref('test_mail.mail_test_full_tracking_tpl').id})
self.assertEqual(self.record.message_ids, self.env['mail.message'])