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') diff --git a/addons/test_mail/tests/test_mail_composer.py b/addons/test_mail/tests/test_mail_composer.py index beed5150276..589f4105176 100644 --- a/addons/test_mail/tests/test_mail_composer.py +++ b/addons/test_mail/tests/test_mail_composer.py @@ -107,8 +107,7 @@ class TestComposerForm(TestMailComposer): @users('employee') def test_mail_composer_mass(self): composer_form = Form(self.env['mail.compose.message'].with_context(self._get_web_context(self.test_records, add_web=True))) - # TDE FIXME: currently failing - # self.assertFalse(composer_form.subject, 'MailComposer: mass mode should have void default subject if no template') + self.assertFalse(composer_form.subject, 'MailComposer: mass mode should have void default subject if no template') # record name not displayed currently in view # self.assertFalse(composer_form.record_name, 'MailComposer: mass mode should have void record name') self.assertFalse(composer_form.no_auto_thread)