[patch-fix] make_email_accounts
This commit is contained in:
parent
2c78796716
commit
39539f14ce
@ -46,20 +46,7 @@ def execute():
|
||||
account.enable_outgoing = 0
|
||||
account.append_to = "Issue"
|
||||
|
||||
try:
|
||||
account.insert()
|
||||
except frappe.NameError, e:
|
||||
if e.args[0]=="Email Account":
|
||||
existing_account = frappe.get_doc("Email Account", e.args[1])
|
||||
for key, value in account.as_dict().items():
|
||||
if not existing_account.get(key) and value and key not in default_fields:
|
||||
existing_account.set(key, value)
|
||||
|
||||
existing_account.save()
|
||||
|
||||
else:
|
||||
raise
|
||||
|
||||
insert_or_update(account)
|
||||
|
||||
# sales, jobs
|
||||
for doctype in ("Sales Email Settings", "Jobs Email Settings"):
|
||||
@ -80,20 +67,25 @@ def execute():
|
||||
account.enable_outgoing = 0
|
||||
account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
|
||||
|
||||
try:
|
||||
account.insert()
|
||||
except frappe.NameError, e:
|
||||
if e.args[0]=="Email Account":
|
||||
existing_account = frappe.get_doc("Email Account", e.args[1])
|
||||
for key, value in account.as_dict().items():
|
||||
if not existing_account.get(key) and value and key not in default_fields:
|
||||
existing_account.set(key, value)
|
||||
|
||||
existing_account.save()
|
||||
else:
|
||||
raise
|
||||
insert_or_update(account)
|
||||
|
||||
for doctype in ("Outgoing Email Settings", "Support Email Settings",
|
||||
"Sales Email Settings", "Jobs Email Settings"):
|
||||
frappe.delete_doc("DocType", doctype)
|
||||
|
||||
def insert_or_update(account):
|
||||
try:
|
||||
account.insert()
|
||||
except frappe.NameError, e:
|
||||
if e.args[0]=="Email Account":
|
||||
existing_account = frappe.get_doc("Email Account", e.args[0])
|
||||
for key, value in account.as_dict().items():
|
||||
if not existing_account.get(key) and value \
|
||||
and key not in default_fields \
|
||||
and key != "__islocal":
|
||||
existing_account.set(key, value)
|
||||
|
||||
existing_account.save()
|
||||
else:
|
||||
raise
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user