diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 28a9c66baa5..f93d59299b4 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -90,10 +90,6 @@ class mail_notification(osv.Model): if partner.notification_email_pref=='comment' and msg.type in ('email','comment'): continue - if not msg.email_from: - current_user = res_users_obj.browse(cr, uid, uid, context=context) - towrite['email_from'] = current_user.email - towrite['state'] = 'outgoing' if not towrite.get('email_to', False): towrite['email_to'] = email_to @@ -109,5 +105,3 @@ class mail_notification(osv.Model): newid = mail_message_obj.create(cr, uid, towrite, context=context) mail_message_obj.send(cr, uid, [newid], context=context) return True - - diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index cae27e99a55..3d7c6fa2ec7 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -1,4 +1,3 @@ - import ast import base64 import email @@ -45,9 +44,16 @@ class mail_mail(osv.Model): 'body_html': fields.text('Rich-text Contents', help="Rich-text/HTML version of the message"), } + def _get_default_from(self, cr, uid, context={}): + cur = self.pool.get('res.users').browse(cr, uid, uid, context=context) + if not cur.alias_domain: + raise osv.except_osv(_('Invalid Action!'), _('Unable to send email, set an alias domain in your server settings.')) + return cur.alias_name + '@' + cur.alias_domain + _defaults = { 'state': 'outgoing', 'content_subtype': 'plain', + 'email_from': _get_default_from } def mark_outgoing(self, cr, uid, ids, context=None): diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 7e33e4152f0..e37b035c16a 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -100,11 +100,6 @@ class mail_compose_message(osv.TransientModel): result['model'] = active_model if not result.get('res_id') and active_id: result['res_id'] = active_id - - # Try to provide default email_from if not specified yet - if not result.get('email_from'): - current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - result['email_from'] = current_user.email or False return result _columns = { @@ -139,7 +134,6 @@ class mail_compose_message(osv.TransientModel): 'model': model, 'res_id': res_id, 'email_from': user.email or tools.config.get('email_from', False), - 'body_html': False, 'body': False, 'subject': False, 'dest_partner_ids': [], @@ -199,44 +193,28 @@ class mail_compose_message(osv.TransientModel): reply_subject = tools.ustr(message_data.subject or '') if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)): reply_subject = "%s %s" % (re_prefix, reply_subject) + # Form the bodies (text and html). We use the plain text version of the # original mail, by default, as it is easier to quote than the HTML # version. TODO: make it possible to switch to HTML on the fly + sent_date = _('On %(date)s, ') % {'date': message_data.date} if message_data.date else '' sender = _('%(sender_name)s wrote:') % {'sender_name': tools.ustr(message_data.email_from or _('You'))} + body = message_data.body or '' - body_html = message_data.body_html or '' - quoted_body = '> %s' % tools.ustr(body.replace('\n', "\n> ") or '') - quoted_body_html = '
%s' % (tools.ustr(body_html)), - reply_body = '\n%s%s\n%s\n%s' % (sent_date, sender, quoted_body, current_user.signature) - reply_body_html = '
%s' % (tools.ustr(body)), + reply_body = '