[patch-fix] make_email_accounts
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
index 528fe08..dd74fc9 100644
--- a/erpnext/patches/v4_4/make_email_accounts.py
+++ b/erpnext/patches/v4_4/make_email_accounts.py
@@ -46,20 +46,7 @@
 		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 @@
 			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
+