From 763496be49813da85aecb518116f7ccc7f30eac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Feb 2014 10:48:31 +0100 Subject: [PATCH 1/4] [IMP] mail: added message_last_update field. This field is a datetime field, updated everytime message_post in called. This allows to build filters, search or actions based on the last message date, for reporting for example. bzr revid: tde@openerp.com-20140206094831-nvyds6nqz0v25t59 --- addons/mail/mail_thread.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ee4dcac5414..c1006182000 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -296,6 +296,9 @@ class mail_thread(osv.AbstractModel): auto_join=True, string='Messages', help="Messages and communication history"), + 'message_last_update': fields.datetime('Last Message Date', + help='Date of the last message posted on the record. Only messages going' + 'through the message_post API are taken into account for better performances.'), 'message_unread': fields.function(_get_message_data, fnct_search=_search_message_unread, multi="_get_message_data", type='boolean', string='Unread Messages', @@ -1522,8 +1525,13 @@ class mail_thread(osv.AbstractModel): for x in ('from', 'to', 'cc'): values.pop(x, None) - # Create and auto subscribe the author + # Post the message msg_id = mail_message.create(cr, uid, values, context=context) + + # Post-process: subscribe author, update message_last_update + if model and model != 'mail.thread' and thread_id: + # done with SUPERUSER_ID, because on some models users can post only with read access, not necessarily write access + self.write(cr, SUPERUSER_ID, [thread_id], {'message_last_update': fields.datetime.now()}, context=context) message = mail_message.browse(cr, uid, msg_id, context=context) if message.author_id and thread_id and type != 'notification' and not context.get('mail_create_nosubscribe'): self.message_subscribe(cr, uid, [thread_id], [message.author_id.id], context=context) From 307119bd55a289b3630e76e06f858dc79e7beeb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Mar 2014 10:40:42 +0100 Subject: [PATCH 2/4] [IMP] mail: message_last_update -> message_last_post + only update when having a subtype bzr revid: tde@openerp.com-20140305094042-6f1cne3srq7y1ffn --- addons/mail/mail_thread.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 192571028a2..c72ef8a77cb 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -306,9 +306,8 @@ class mail_thread(osv.AbstractModel): auto_join=True, string='Messages', help="Messages and communication history"), - 'message_last_update': fields.datetime('Last Message Date', - help='Date of the last message posted on the record. Only messages going' - 'through the message_post API are taken into account for better performances.'), + 'message_last_post': fields.datetime('Last Message Date', + help='Date of the last message posted on the record.'), 'message_unread': fields.function(_get_message_data, fnct_search=_search_message_unread, multi="_get_message_data", type='boolean', string='Unread Messages', @@ -1558,10 +1557,10 @@ class mail_thread(osv.AbstractModel): # Post the message msg_id = mail_message.create(cr, uid, values, context=context) - # Post-process: subscribe author, update message_last_update - if model and model != 'mail.thread' and thread_id: + # Post-process: subscribe author, update message_last_post + if model and model != 'mail.thread' and thread_id and subtype_id: # done with SUPERUSER_ID, because on some models users can post only with read access, not necessarily write access - self.write(cr, SUPERUSER_ID, [thread_id], {'message_last_update': fields.datetime.now()}, context=context) + self.write(cr, SUPERUSER_ID, [thread_id], {'message_last_post': fields.datetime.now()}, context=context) message = mail_message.browse(cr, uid, msg_id, context=context) if message.author_id and thread_id and type != 'notification' and not context.get('mail_create_nosubscribe'): self.message_subscribe(cr, uid, [thread_id], [message.author_id.id], context=context) From 629971815f3d558a3cfaf829c409eb71a048737e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Mar 2014 10:44:11 +0100 Subject: [PATCH 3/4] [IMP] project_issue: add last post in groupby bzr revid: tde@openerp.com-20140305094411-eiwcygl0e9divkj0 --- addons/project_issue/project_issue_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 68c6712f530..3af9ee608d6 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -160,6 +160,7 @@ + From dab275e931e4cc771b803f16bd098991b0eada74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Mar 2014 10:44:27 +0100 Subject: [PATCH 4/4] [IMP] crm: add message_last_pos tin groupby for leads and opportunities bzr revid: tde@openerp.com-20140305094427-6295fmowatllrxxz --- addons/crm/crm_lead_view.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index e76a7a9124d..d054e956ed6 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -359,6 +359,7 @@ + @@ -578,6 +579,7 @@ +