[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
This commit is contained in:
parent
fd008435e0
commit
763496be49
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue