diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 9391a931774..3de4d700885 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -204,18 +204,6 @@ class mail_message(osv.osv): msg_id = super(mail_message, self).create(cr, uid, vals, context) return msg_id - def get_pushed_messages(self, cr, uid, ids, filter_search=False, context=None): - """OpenSocial: wall: get messages to display (=pushed notifications) - :param filter_search: TODO - :return: list of mail.messages, unsorted - """ - notification_obj = self.pool.get('mail.notification') - notification_ids = notification_obj.search(cr, uid, [('user_id', '=', uid)], context=context) - notifications = notification_obj.browse(cr, uid, notification_ids, context=context) - msg_ids = [notification.message_id.id for notification in notifications] - msgs = self.read(cr, uid, msg_ids, context=context) - return msgs - #------------------------------------------------------ # E-Mail api #------------------------------------------------------ diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 12768d1664c..67669deaafd 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -284,13 +284,25 @@ class mail_thread(osv.osv): limit=limit, offset=offset, context=context) return msg_ids - def message_load(self, cr, uid, ids, limit=50, offset=0, context=None): + def message_load(self, cr, uid, ids, limit=5, offset=0, context=None): """ OpenSocial feature: return thread messages loading messages: search in mail.messages where res_id = ids, (res_)model = current model """ msg_ids = self.message_load_ids(cr, uid, ids, limit=limit, offset=offset, context=context) return self.pool.get('mail.message').read(cr, uid, msg_ids, context=context) - + + def get_pushed_messages(self, cr, uid, ids, filter_search=False, limit=5, offset=0, context=None): + """OpenSocial: wall: get messages to display (=pushed notifications) + :param filter_search: TODO + :return: list of mail.messages, unsorted + """ + notification_obj = self.pool.get('mail.notification') + notification_ids = notification_obj.search(cr, uid, [('user_id', '=', uid)], limit=limit, offset=offset, context=context) + notifications = notification_obj.browse(cr, uid, notification_ids, context=context) + msg_ids = [notification.message_id.id for notification in notifications] + msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, context=context) + return msgs + #------------------------------------------------------ # Email specific #------------------------------------------------------ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 98df2ceec7f..8bf359e096a 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -18,6 +18,7 @@ openerp.mail = function(session) { this.res_model = params['res_model']; this.res_id = params['res_id']; this.uid = params['uid']; + this.records = params['records'] || false; /* DataSets */ this.ds = new session.web.DataSet(this, this.res_model); this.ds_users = new session.web.DataSet(this, 'res.users'); @@ -43,7 +44,8 @@ openerp.mail = function(session) { }); /* display user, fetch comments */ this.display_current_user(); - this.fetch_comments(); + if (this.records == false) this.fetch_comments(); + else this.display_comments(this.records); }, stop: function () { @@ -228,7 +230,7 @@ openerp.mail = function(session) { this._super(parent); this.filter_search = params['filter_search']; /* DataSets */ - this.ds_msg = new session.web.DataSet(this, 'mail.message'); + this.ds_thread = new session.web.DataSet(this, 'mail.thread'); this.ds_users = new session.web.DataSet(this, 'res.users'); }, @@ -244,7 +246,7 @@ openerp.mail = function(session) { }, fetch_comments: function () { - var load_res = this.ds_msg.call('get_pushed_messages', [[this.session.uid]]).then( + var load_res = this.ds_thread.call('get_pushed_messages', [[this.session.uid]]).then( this.proxy('display_comments')); return load_res; }, @@ -261,7 +263,9 @@ openerp.mail = function(session) { 'record_id': id, }); $('
').html(render_res).appendTo(self.$element.find('div.oe_mail_wall_threads')); - self.thread_display = new mail.ThreadDisplay(self, {'res_model': model, 'res_id': parseInt(id), 'uid': self.session.uid}); + self.thread_display = new mail.ThreadDisplay(self, + {'res_model': model, 'res_id': parseInt(id), 'uid': self.session.uid, 'records': record_id} + ); self.thread_display.appendTo(self.$element.find('div.oe_mail_wall_thread_content:last')); }); });