diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index cad467a37f9..f62a10338de 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -3,7 +3,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2009 Sharoon Thomas -# Copyright (C) 2010-2010 OpenERP SA () +# Copyright (C) 2010-2011 OpenERP SA () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -84,10 +84,10 @@ class email_template(osv.osv): 'name' : fields.char('Name', size=100, required=True), 'object_name':fields.many2one('ir.model', 'Resource'), 'model_int_name':fields.char('Model Internal Name', size=200,), - 'from_account':fields.many2one( + 'smtp_server_id':fields.many2one( 'email.smtp_server', - string="Email Account", - help="Emails will be sent from this approved account."), + string="SMTP Server", + help="Emails will be sent from this SMTP Server."), 'def_to':fields.char( 'Recipient (To)', size=250, @@ -478,12 +478,12 @@ This is useful for CRM leads for example"), context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): - from_account = self.pool.get('email.smtp_server').read(cursor, user, context.get('account_id'), ['name', 'email_id'], context) + smtp_server_id = self.pool.get('email.smtp_server').read(cursor, user, context.get('account_id'), ['name', 'email_id'], context) else: - from_account = { - 'id':template.from_account.id, - 'name':template.from_account.name, - 'email_id':template.from_account.email_id + smtp_server_id = { + 'id':template.smtp_server_id.id, + 'name':template.smtp_server_id.name, + 'email_id':template.smtp_server_id.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: @@ -493,13 +493,13 @@ This is useful for CRM leads for example"), # determine name of sender, either it is specified in email_id or we # use the account name - email_id = from_account['email_id'].strip() + email_id = smtp_server_id['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address - email_from = from_account['email_id'] + email_from = smtp_server_id['email_id'] else: - email_from = tools.ustr(from_account['name']) + "<" + tools.ustr(email_id) + ">" + email_from = tools.ustr(smtp_server_id['name']) + "<" + tools.ustr(email_id) + ">" # FIXME: should do this in a loop and rename template fields to the corresponding # mailbox fields. (makes no sense to have different names I think. diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index 201b0af232e..938b4246537 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -16,7 +16,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -135,7 +135,7 @@ - + diff --git a/addons/email_template/wizard/email_template_send_wizard.py b/addons/email_template/wizard/email_template_send_wizard.py index 6c07443dab4..ac6fe5c9f9c 100644 --- a/addons/email_template/wizard/email_template_send_wizard.py +++ b/addons/email_template/wizard/email_template_send_wizard.py @@ -47,8 +47,8 @@ class email_template_send_wizard(osv.osv_memory): logger = netsvc.Logger() - if template.from_account: - return [(template.from_account.id, '%s (%s)' % (template.from_account.name, template.from_account.email_id))] + if template.smtp_server_id: + return [(template.smtp_server_id.id, '%s (%s)' % (template.smtp_server_id.name, template.smtp_server_id.email_id))] else: logger.notifyChannel(_("email-template"), netsvc.LOG_ERROR, _("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account.")) raise osv.except_osv(_("Missing mail account"),_("No personal email accounts are configured for you. \nEither ask admin to enforce an account for this template or get yourself a personal email account.")) diff --git a/addons/emails/email_smtp_server.py b/addons/emails/email_smtp_server.py index b0a1793b64b..2500c6cd457 100644 --- a/addons/emails/email_smtp_server.py +++ b/addons/emails/email_smtp_server.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL () +# Copyright (C) 2004-2011 Tiny SPRL () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as