[MERGE] forward port of branch 7.0 up to 15ee4d8
authorChristophe Simonis <chs@odoo.com>
Thu, 28 Aug 2014 17:07:11 +0000 (19:07 +0200)
committerChristophe Simonis <chs@odoo.com>
Thu, 28 Aug 2014 17:07:11 +0000 (19:07 +0200)
1  2 
addons/email_template/wizard/mail_compose_message.py

@@@ -41,28 -39,26 +41,28 @@@ def _reopen(self, res_id, model)
  class mail_compose_message(osv.TransientModel):
      _inherit = 'mail.compose.message'
  
 -    def _get_templates(self, cr, uid, context=None):
 +    def default_get(self, cr, uid, fields, context=None):
 +        """ Override to pre-fill the data when having a template in single-email mode """
          if context is None:
              context = {}
 -        model = False
 -        email_template_obj = self.pool.get('email.template')
 -        message_id = context.get('default_parent_id', context.get('message_id', context.get('active_id')))
 -
 -        if context.get('default_composition_mode') == 'reply' and message_id:
 -            message_data = self.pool.get('mail.message').browse(cr, uid, message_id, context=context)
 -            if message_data:
 -                model = message_data.model
 -        else:
 -            model = context.get('default_model', context.get('active_model'))
 -
 -        record_ids = email_template_obj.search(cr, uid, [('model', '=', model)], context=context)
 -        return email_template_obj.name_get(cr, uid, record_ids, context) + [(False, '')]
 +        res = super(mail_compose_message, self).default_get(cr, uid, fields, context=context)
 +        if res.get('composition_mode') != 'mass_mail' and context.get('default_template_id') and res.get('model') and res.get('res_id'):
 +            res.update(
 +                self.onchange_template_id(
 +                    cr, uid, [], context['default_template_id'], res.get('composition_mode'),
 +                    res.get('model'), res.get('res_id', context.get('active_id')), context=context
 +                )['value']
 +            )
 +        return res
  
      _columns = {
-         'template_id': fields.many2one('email.template', 'Use template', select=True, groups="base.group_user"),
 -        # incredible hack of the day: size=-1 means we want an int db column instead of an str one
 -        'template_id': fields.selection(_get_templates, 'Template', size=-1),
++        'template_id': fields.many2one('email.template', 'Use template', select=True),
 +        'partner_to': fields.char('To (Partner IDs)',
 +            help="Comma-separated list of recipient partners ids (placeholders may be used here)"),
 +        'email_to': fields.char('To (Emails)',
 +            help="Comma-separated recipient addresses (placeholders may be used here)",),
 +        'email_cc': fields.char('Cc (Emails)',
 +            help="Carbon copy recipients (placeholders may be used here)"),
      }
  
      def send_mail(self, cr, uid, ids, context=None):