From 0d4fdc41f9bec83c20ac66be62d4da066ba601c2 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 29 Oct 2012 10:29:34 +0100 Subject: [PATCH] [FIX] mail: resolve error to read message after posting bzr revid: chm@openerp.com-20121029092934-gqfg7gq90xs8w3k1 --- addons/mail/mail_message.py | 9 --------- addons/mail/res_users.py | 4 ++-- addons/mail/static/src/js/mail.js | 24 +++++++++++++----------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 6eb4edf25e3..e5e9dfce788 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -386,13 +386,6 @@ class mail_message(osv.Model): ancestors and expandables :return list: list of message structure for the Chatter widget """ - print domain - print message_unload_ids - print thread_level - print context - print parent_id - print limit - assert thread_level in [0, 1], 'message_read() thread_level should be 0 (flat) or 1 (1 level of thread); given %s.' % thread_level domain = domain if domain is not None else [] message_unload_ids = message_unload_ids if message_unload_ids is not None else [] @@ -432,8 +425,6 @@ class mail_message(osv.Model): self._message_read_add_expandables(cr, uid, message_list, read_messages, thread_level=thread_level, message_loaded_ids=message_unload_ids, domain=domain, parent_id=parent_id, context=context, limit=limit) - print message_list - return message_list # TDE Note: do we need this ? diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 54b8a76703f..4ef2dda6d9c 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -112,7 +112,7 @@ class res_users(osv.Model): return res def message_post_api(self, cr, uid, thread_id, body='', subject=False, type='notification', - subtype=None, parent_id=False, attachments=None, context=None, **kwargs): + parent_id=False, attachment_ids=None, context=None, **kwargs): """ Redirect the posting of message on res.users to the related partner. This is done because when giving the context of Chatter on the various mailboxes, we do not have access to the current partner_id. @@ -124,7 +124,7 @@ class res_users(osv.Model): thread_id = thread_id[0] partner_id = self.pool.get('res.users').read(cr, uid, thread_id, ['partner_id'], context=context)['partner_id'][0] return self.pool.get('res.partner').message_post_api(cr, uid, partner_id, body=body, subject=subject, - type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, **kwargs) + type=type, parent_id=parent_id, attachment_ids=attachment_ids, context=context, **kwargs) def message_post(self, cr, uid, thread_id, context=None, **kwargs): """ Redirect the posting of message on res.users to the related partner. diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 27ffdebfc5a..28ba0e66923 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -365,15 +365,17 @@ openerp.mail = function (session) { ]).then(function (record) { var thread = self.parent_thread; // create object and attach to the thread object - var message = thread.create_message_object( record[0] ); - // insert the message on dom - thread.insert_message( message, self.$el ); - if (thread.parent_message) { - self.$el.remove(); - self.parent_thread.compose_message = null; - } else { - self.on_cancel(); - } + thread.message_fetch(false, false, [record], function (arg, data) { + var message = thread.create_message_object( data[0] ); + // insert the message on dom + thread.insert_message( message, self.$el ); + if (thread.parent_message) { + self.$el.remove(); + self.parent_thread.compose_message = null; + } else { + self.on_cancel(); + } + }); //session.web.unblockUI(); }); return true; @@ -1107,7 +1109,7 @@ openerp.mail = function (session) { * @param {Object} replace_context: added to this.context * @param {Array} ids read (if the are some ids, the method don't use the domain) */ - message_fetch: function (replace_domain, replace_context, ids) { + message_fetch: function (replace_domain, replace_context, ids, callback) { var self = this; // domain and context: options + additional @@ -1119,7 +1121,7 @@ openerp.mail = function (session) { var nb_indented_thread = this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0; return this.ds_message.call('message_read', [ids, fetch_domain, message_loaded_ids, nb_indented_thread, fetch_context, this.context.default_parent_id || undefined]) - .then(this.proxy('switch_new_message')); + .then(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message')); }, /**