From 2478d1b22171095341a8216a9177e55400b28192 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 14 Feb 2013 13:02:57 +0100 Subject: [PATCH] [FIX] mail.thread: allow re-entry in message_post in case of cross-model notifications via message_process Previously the `thread_model` key in the context would cause issues if an incoming message processed by message_process() triggered another message_post() call in a different model, because the `thead_model` would be incorrect in the second call. bzr revid: odo@openerp.com-20130214120257-c12fkj6pgont9ies --- addons/mail/mail_thread.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 7a2be4aed01..118118681ac 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -592,7 +592,7 @@ class mail_thread(osv.AbstractModel): thread_id = False for model, thread_id, custom_values, user_id in routes: - if self._name != model: + if self._name == 'mail.thread': context.update({'thread_model': model}) if model: model_pool = self.pool.get(model) @@ -883,7 +883,12 @@ class mail_thread(osv.AbstractModel): if isinstance(thread_id, (list, tuple)): thread_id = thread_id and thread_id[0] mail_message = self.pool.get('mail.message') - model = context.get('thread_model', self._name) if thread_id else False + + # if we're processing a message directly coming from the gateway, the destination model was + # set in the context. + model = False + if thread_id: + model = context.get('thread_model', self._name) if self._name == 'mail.thread' else self._name attachment_ids = kwargs.pop('attachment_ids', []) for name, content in attachments: