[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.enable_outgoing = 0
|
||||||
account.append_to = "Issue"
|
account.append_to = "Issue"
|
||||||
|
|
||||||
try:
|
insert_or_update(account)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
# sales, jobs
|
# sales, jobs
|
||||||
for doctype in ("Sales Email Settings", "Jobs Email Settings"):
|
for doctype in ("Sales Email Settings", "Jobs Email Settings"):
|
||||||
@ -80,20 +67,25 @@ def execute():
|
|||||||
account.enable_outgoing = 0
|
account.enable_outgoing = 0
|
||||||
account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
|
account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
|
||||||
|
|
||||||
try:
|
insert_or_update(account)
|
||||||
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
|
|
||||||
|
|
||||||
for doctype in ("Outgoing Email Settings", "Support Email Settings",
|
for doctype in ("Outgoing Email Settings", "Support Email Settings",
|
||||||
"Sales Email Settings", "Jobs Email Settings"):
|
"Sales Email Settings", "Jobs Email Settings"):
|
||||||
frappe.delete_doc("DocType", doctype)
|
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