[ADD] mail.thread: added automatic forward of message when @login is present in body. Also fixed a bug when posting a comment from the wall.

bzr revid: tde@openerp.com-20120308112445-ndv0b1x82kv2uanp
This commit is contained in:
Thibault Delavallée
2012-03-08 12:24:45 +01:00
parent 6ce4a48ce9
commit 63a16e7074
3 changed files with 16 additions and 6 deletions
+9 -4
View File
@@ -25,6 +25,7 @@ import base64
import email
from email.utils import parsedate
import re
import logging
import xmlrpclib
from osv import osv, fields
@@ -119,15 +120,19 @@ class mail_thread(osv.osv):
notification_obj.create(cr, uid, {'user_id': vals['need_action_user_id'], 'message_id': msg_id}, context=context)
# parse message to get requested users
user_ids = self.message_parse_users(cr, uid, [msg_id], 'body_text', context=context)
user_ids = self.message_parse_users(cr, uid, [msg_id], vals['body_text'], context=context)
for user_id in user_ids:
print 'pushed to %d' % (user_id)
notification_obj.create(cr, uid, {'user_id': user_id, 'message_id': msg_id}, context=context)
return msg_id
def message_parse_users(self, cr, uid, ids, field_name='body_text', context=None):
'''Parse message content; if find @login: returns the related id'''
user_ids = []
def message_parse_users(self, cr, uid, ids, string, context=None):
'''Parse message content; if find @login -(^|\s)@(\w*)-: returns the related ids'''
regex = re.compile('(^|\s)@(\w*)')
login_lst = [item[1] for item in regex.findall(string)]
if not login_lst: return []
user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context=context)
return user_ids
def message_capable_models(self, cr, uid, context=None):
+6 -1
View File
@@ -82,7 +82,12 @@
.oe_mail_thread {
}
.oe_mail_thread_display, .oe_mail_thread_act {
.oe_mail_thread_act {
white-space: normal;
margin-bottom: 5px;
}
.oe_mail_thread_display {
white-space: normal;
margin-bottom: 5px;
border-bottom: 1px solid #D2D9E7;
+1 -1
View File
@@ -667,7 +667,7 @@ openerp.mail = function(session) {
*/
do_comment: function () {
var body_text = this.$element.find('textarea.oe_mail_wall_action_textarea').val();
return this.ds_users.call('message_append_note', [[this.session.uid], 'Tweet', body_text, type='comment']).then(this.init_comments());
return this.ds_users.call('message_append_note', [[this.session.uid], 'Tweet', body_text, false, 'comment']).then(this.init_comments());
},
/**