2014-03-03 15:02:20 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
2014-09-15 11:29:38 +00:00
|
|
|
print "WARNING!!!! Email Settings not migrated. Please setup your email again."
|
|
|
|
|
|
|
|
# this will happen if you are migrating very old accounts
|
|
|
|
# comment out this line below and remember to create new Email Accounts
|
|
|
|
# for incoming and outgoing mails
|
|
|
|
raise Exception
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2014-03-03 15:02:20 +00:00
|
|
|
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
|
|
|
frappe.reload_doc("support", "doctype", "support_email_settings")
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-05-09 06:31:25 +00:00
|
|
|
email_settings = get_email_settings()
|
2014-03-03 15:02:20 +00:00
|
|
|
map_outgoing_email_settings(email_settings)
|
|
|
|
map_support_email_settings(email_settings)
|
2014-05-29 14:37:10 +00:00
|
|
|
|
|
|
|
|
2014-03-03 15:02:20 +00:00
|
|
|
def map_outgoing_email_settings(email_settings):
|
2014-03-28 11:14:37 +00:00
|
|
|
outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
|
2014-05-29 14:37:10 +00:00
|
|
|
for fieldname in (("outgoing_mail_server", "mail_server"),
|
2014-03-03 15:02:20 +00:00
|
|
|
"use_ssl", "mail_port", "mail_login", "mail_password",
|
2014-07-07 06:59:43 +00:00
|
|
|
"always_use_login_id_as_sender", "auto_email_id"):
|
2014-03-03 15:02:20 +00:00
|
|
|
|
|
|
|
if isinstance(fieldname, tuple):
|
|
|
|
from_fieldname, to_fieldname = fieldname
|
|
|
|
else:
|
|
|
|
from_fieldname = to_fieldname = fieldname
|
|
|
|
|
2014-03-28 08:25:00 +00:00
|
|
|
outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
|
2014-03-03 15:02:20 +00:00
|
|
|
|
2014-06-12 09:30:25 +00:00
|
|
|
outgoing_email_settings._fix_numeric_types()
|
2014-03-03 15:02:20 +00:00
|
|
|
outgoing_email_settings.save()
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-03-03 15:02:20 +00:00
|
|
|
def map_support_email_settings(email_settings):
|
2014-03-28 11:14:37 +00:00
|
|
|
support_email_settings = frappe.get_doc("Support Email Settings")
|
2014-05-29 14:37:10 +00:00
|
|
|
|
|
|
|
for fieldname in ("sync_support_mails", "support_email",
|
|
|
|
("support_host", "mail_server"),
|
|
|
|
("support_use_ssl", "use_ssl"),
|
|
|
|
("support_username", "mail_login"),
|
|
|
|
("support_password", "mail_password"),
|
2014-03-03 15:02:20 +00:00
|
|
|
"support_signature", "send_autoreply", "support_autoreply"):
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-03-03 15:02:20 +00:00
|
|
|
if isinstance(fieldname, tuple):
|
|
|
|
from_fieldname, to_fieldname = fieldname
|
|
|
|
else:
|
|
|
|
from_fieldname = to_fieldname = fieldname
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-03-28 08:25:00 +00:00
|
|
|
support_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-06-12 09:30:25 +00:00
|
|
|
support_email_settings._fix_numeric_types()
|
2014-03-03 15:02:20 +00:00
|
|
|
support_email_settings.save()
|
2014-05-29 14:37:10 +00:00
|
|
|
|
2014-05-09 06:31:25 +00:00
|
|
|
def get_email_settings():
|
|
|
|
ret = {}
|
|
|
|
for field, value in frappe.db.sql("select field, value from tabSingles where doctype='Email Settings'"):
|
|
|
|
ret[field] = value
|
|
|
|
return ret
|
|
|
|
|