summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2016-11-24 17:51:56 +0100
committerThibault Delavallée <tde@odoo.com>2016-12-30 10:45:39 +0100
commit64ea747824dc5580f35c8af904029139ef2fb4bc (patch)
tree20c087b6e378111a456318473e858560eac1a2e6
parent72d988cba5a7e4bebd10ddd9e3b0c8b721b9534d (diff)
[FIX] mail: fix record model and ids management when posting using a template
Posting on a document not inheriting from mail_thread was impossible due to several crashes or wrongly set variables. Some cleaning is planned in those methods as there are a lot of unnecessary computation. This will be done in another commit. Probably.
-rw-r--r--addons/mail/models/mail_thread.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index df7ba1821e5..f0e6970bcce 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -1923,15 +1923,17 @@ class MailThread(models.AbstractModel):
kwargs['composition_mode'] = 'comment' if len(self.ids) == 1 else 'mass_mail'
if not kwargs.get('message_type'):
kwargs['message_type'] = 'notification'
- res_id = self.ids[0] or 0
+ res_id = kwargs.get('res_id', self.ids and self.ids[0] or 0)
+ res_ids = kwargs.get('res_id') and [kwargs['res_id']] or self.ids
# Create the composer
composer = self.env['mail.compose.message'].with_context(
- active_ids=self.ids,
- active_model=self._name,
+ active_id=res_id,
+ active_ids=res_ids,
+ active_model=kwargs.get('model', self._name),
default_composition_mode=kwargs['composition_mode'],
- default_model=self._name,
- default_res_id=self.ids[0] or 0,
+ default_model=kwargs.get('model', self._name),
+ default_res_id=res_id,
default_template_id=template_id,
).create(kwargs)
# Simulate the onchange (like trigger in form the view) only