summaryrefslogtreecommitdiff
path: root/addons/mail/wizard/mail_compose_message.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
-rw-r--r--addons/mail/wizard/mail_compose_message.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index d5800ded589..8c84376356b 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -63,25 +63,22 @@ class MailComposer(models.TransientModel):
if missing_author:
result['author_id'] = author_id
- result['composition_mode'] = result.get('composition_mode', 'comment')
- result['model'] = result.get('model', self._context.get('active_model'))
- result['res_id'] = result.get('res_id', self._context.get('active_id'))
- if 'no_auto_thread' not in result and (result['model'] not in self.env or not hasattr(self.env[result['model']], 'message_post')):
- result['no_auto_thread'] = True
+ if 'model' in fields and 'model' not in result:
+ result['model'] = self._context.get('active_model')
+ if 'res_id' in fields and 'res_id' not in result:
+ result['res_id'] = self._context.get('active_id')
+ if 'no_auto_thread' in fields and 'no_auto_thread' not in result and result.get('model'):
+ # doesn't support threading
+ if result['model'] not in self.env or not hasattr(self.env[result['model']], 'message_post'):
+ result['no_auto_thread'] = True
- vals = {}
if 'active_domain' in self._context: # not context.get() because we want to keep global [] domains
- vals['active_domain'] = '%s' % self._context.get('active_domain')
- if result['composition_mode'] == 'comment':
- vals.update(self.get_record_data(result))
+ result['active_domain'] = '%s' % self._context.get('active_domain')
+ if result.get('composition_mode') == 'comment' and (set(fields) & set(['model', 'res_id', 'partner_ids', 'record_name', 'subject'])):
+ result.update(self.get_record_data(result))
- for field in vals:
- if field in fields:
- result[field] = vals[field]
-
- if fields is not None:
- [result.pop(field, None) for field in list(result) if field not in fields]
- return result
+ filtered_result = dict((fname, result[fname]) for fname in result if fname in fields)
+ return filtered_result
# content
subject = fields.Char('Subject')