From 1b8d1908293300f2b2475df028b48d3a522fae90 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 19 Aug 2012 18:28:32 +0200 Subject: [PATCH] [IMP] merging _get_pushed_messages and message_read, still have to add a domain on message_read based on notifications bzr revid: fp@openerp.com-20120819162832-ffzlm7zej7qrn11l --- addons/mail/mail_thread.py | 34 ------------------------------- addons/mail/static/src/js/mail.js | 12 ++++++----- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index de4759dd835..6c9d4dc3904 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -278,40 +278,6 @@ class mail_thread(osv.Model): messages = sorted(messages, key=lambda d: (-d['id'])) return messages - def message_get_pushed_messages(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, msg_search_domain=[], context=None): - """ OpenChatter: wall: get the pushed notifications and used them - to fetch messages to display on the wall. - - :param fetch_ancestors: performs an ascended search; will add - to fetched msgs all their parents until - ancestor_ids - :param ancestor_ids: used when fetching ancestors - :param domain: domain to add to the search; especially child_of - is interesting when dealing with threaded display - :param ascent: performs an ascended search; will add to fetched msgs - all their parents until root_ids - :param root_ids: for ascent search - :return: list of mail.messages sorted by date - """ - notification_obj = self.pool.get('mail.notification') - msg_obj = self.pool.get('mail.message') - # update message search - for arg in msg_search_domain: - if isinstance(arg, (tuple, list)): - arg[0] = 'message_id.' + arg[0] - # compose final domain - domain = [('user_id', '=', uid)] + msg_search_domain - # get notifications - notification_ids = notification_obj.search(cr, uid, domain, 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] - # get messages - msg_ids = msg_obj.search(cr, uid, [('id', 'in', msg_ids)], context=context) - if (fetch_ancestors): msg_ids = self._message_search_ancestor_ids(cr, uid, ids, msg_ids, ancestor_ids, context=context) - msgs = msg_obj.read(cr, uid, msg_ids, context=context) - return msgs - def _message_find_partners(self, cr, uid, message, headers=['From'], context=None): s = ', '.join([decode(message.get(h)) for h in headers]) mails = tools.email_split(s) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index f619480aaf4..9612f73a6b8 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -529,6 +529,7 @@ openerp.mail = function(session) { // this.params.limit = 3; // tmp for testing this.params.offset = this.params.offset || 0; this.params.records = this.params.records || null; + // datasets and internal vars this.ds = new session.web.DataSetSearch(this, this.params.res_model); this.ds_users = new session.web.DataSetSearch(this, 'res.users'); @@ -550,6 +551,7 @@ openerp.mail = function(session) { this.bind_events(); // display user, fetch comments this.display_current_user(); + if (this.params.records) var display_done = this.display_comments_from_parameters(this.params.records); else var display_done = this.init_comments(); // customize display @@ -747,10 +749,10 @@ openerp.mail = function(session) { record.mini_url = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.users', 'image_small', record.user_id[0]); } // body text manipulation - if (record.subtype == 'plain') { - record.body = mail.ChatterUtils.do_text_remove_html_tags(record.body); - } - record.body = mail.ChatterUtils.do_replace_expressions(record.body); + // if (record.subtype == 'plain') { + // record.body = mail.ChatterUtils.do_text_remove_html_tags(record.body); + // } + // record.body = mail.ChatterUtils.do_replace_expressions(record.body); // format date according to the user timezone record.date = session.web.format_value(record.date, {type:"datetime"}); // is the user the author ? @@ -1041,7 +1043,7 @@ openerp.mail = function(session) { else var fetch_domain = this.search['domain']; if (additional_context) var fetch_context = _.extend(this.search['context'], additional_context); else var fetch_context = this.search['context']; - return this.ds_thread.call('message_get_pushed_messages', + return this.ds_thread.call('message_read', [[this.session.uid], true, [], (limit || 0), (offset || 0), fetch_domain, fetch_context]).then(this.proxy('display_comments')); },