From 0ef0b3df61b32e621bd5e0c07c735378417543e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 16:17:40 +0200 Subject: [PATCH] [FIX] Chatter: fixed reloading when posting a message; added domain for record threads, because there were no default domain on model and res_id. bzr revid: tde@openerp.com-20120911141740-8t43y4hq5s79z34i --- addons/mail/static/src/js/mail.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 9a8de1480de..6eedabb23b8 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -416,12 +416,12 @@ openerp.mail = function(session) { // domain and context: options + additional fetch_domain = _.flatten([this.options.domain, additional_domain || []], true) fetch_context = _.extend(this.options.context, additional_context || {}) - // if message_ids is set: try to use it + // initial mode: try to use message_data or message_ids if (initial_mode && this.options.message_data) { return this.message_display(this.options.message_data); } - return this.ds_message.call('message_read', - [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, undefined, fetch_context] + message_ids = initial_mode && this.options.message_ids != null && this.options.message_ids || false; + return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, undefined, fetch_context] ).then(this.proxy('message_display')); }, @@ -604,13 +604,16 @@ openerp.mail = function(session) { _.extend(this.options.context, { default_res_id: this.view.datarecord.id, default_model: this.view.model }); + // update domain + var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]); // create and render Thread widget this.$el.find('div.oe_mail_recthread_main').empty(); if (this.thread) { this.thread.destroy(); } var thread = new mail.Thread(self, { - 'context': this.options.context, 'message_ids': this.get_value(), - 'thread_level': this.options.thread_level, 'show_header_compose': true, - 'show_delete': true, 'composer': true }); + 'context': this.options.context, 'domain': domain, 'message_ids': this.get_value(), + // display + 'thread_level': this.options.thread_level, 'show_header_compose': true, 'show_delete': true, 'composer': true, + }); this.thread = thread; return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, @@ -702,13 +705,13 @@ openerp.mail = function(session) { /** Display the Wall threads */ message_display: function () { - var thread_domain = this.options.domain.concat(this.search_results['domain']); + var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); $('
  • ').html(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); var thread = new mail.Thread(this, { - 'domain': thread_domain, 'context': this.options.context, - 'thread_level': this.options.thread_level, 'composer': true, + 'context': this.options.context, 'domain': domain, // display options + 'thread_level': this.options.thread_level, 'composer': true, 'show_header_compose': true, 'show_reply': this.options.thread_level > 0, 'show_hide': true, 'show_reply_by_email': true, }