From 4622059b4d093df90e19154bfee2589f21d23bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 3 Jan 2018 13:53:15 +0100 Subject: [PATCH] [REM] mail: remove 'message_last_post' mechanism Thread mixin class adds a message_last_post field. This field may be updated when a comment is posted, depending on a context key. Since a while this context key is not used anymore. This means the field is never updated. As it is used only as a filter in project we decided to remove it. This commit remove the field and the context key support. This kind of specific feature can be done using customization if necessary in some advanced use case. --- addons/mail/models/mail_thread.py | 13 +------------ addons/project/views/project_views.xml | 2 -- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 1d1d120dcf6..317efc6d09d 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -66,8 +66,6 @@ class MailThread(models.AbstractModel): creating messages - ``tracking_disable``: at create and write, perform no MailThread features (auto subscription, tracking, post, ...) - - ``mail_save_message_last_post``: at message_post, update message_last_post - datetime field - ``mail_auto_delete``: auto delete mail notifications; True by default (technical hack for templates) - ``mail_notify_force_send``: if less than 50 email notifications to send, @@ -95,7 +93,6 @@ class MailThread(models.AbstractModel): message_ids = fields.One2many( 'mail.message', 'res_id', string='Messages', domain=lambda self: [('model', '=', self._name)], auto_join=True) - message_last_post = fields.Datetime('Last Message Date', help='Date of the last message posted on the record.') message_unread = fields.Boolean( 'Unread Messages', compute='_get_message_unread', help="If checked new messages require your attention.") @@ -1907,15 +1904,7 @@ class MailThread(models.AbstractModel): # Post the message new_message = MailMessage.create(values) - # Post-process: subscribe author, update message_last_post - # Note: the message_last_post mechanism is no longer used. This - # will be removed in a later version. - if (self._context.get('mail_save_message_last_post') and - model and model != 'mail.thread' and self.ids and subtype_id): - subtype_rec = self.env['mail.message.subtype'].sudo().browse(subtype_id) - if not subtype_rec.internal: - # done with SUPERUSER_ID, because on some models users can post only with read access, not necessarily write access - self.sudo().write({'message_last_post': fields.Datetime.now()}) + # Post-process: subscribe author if author_id and model and self.ids and message_type != 'notification' and not self._context.get('mail_create_nosubscribe'): self.message_subscribe([author_id], force=False) diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index cf6ef36411c..2adeed7eed4 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -55,8 +55,6 @@ - -