refactor: suggested changes
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 791f71e..fd16b23 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -57,16 +57,16 @@
 		self.payment_terms = ""
 		self.accounts = []
 
-		if not self.accounts and doc.accounts:
+		if doc.accounts:
 			for account in doc.accounts:
 				child = self.append('accounts')
 				child.company = account.company
 				child.account = account.account
-			self.save()
 
-		if not self.payment_terms and doc.payment_terms:
+		if doc.payment_terms:
 			self.payment_terms = doc.payment_terms
 
+		self.save()
 
 	def validate_internal_supplier(self):
 		internal_supplier = frappe.db.get_value("Supplier",
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index cdeb089..3b62081 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -84,25 +84,22 @@
 		self.accounts = self.credit_limits = []
 		self.payment_terms = self.default_price_list = ""
 
-		if not self.accounts and doc.accounts:
-			for account in doc.accounts:
-				child = self.append('accounts')
-				child.company = account.company
-				child.account = account.account
-			self.save()
+		tables = [["accounts", "account"], ["credit_limits", "credit_limit"]]
+		fields = ["payment_terms", "default_price_list"]
 
-		if not self.credit_limits and doc.credit_limits:
-			for credit in doc.credit_limits:
-				child = self.append('credit_limits')
-				child.company = credit.company
-				child.credit_limit = credit.credit_limit
-			self.save()
+		for row in tables:
+			table, field = row[0], row[1]
+			if not doc.get(table): continue
 
-		if not self.payment_terms and doc.payment_terms:
-			self.payment_terms = doc.payment_terms
+			for entry in doc.get(table):
+				child = self.append(table)
+				child.update({"company": entry.company, field: entry.get(field)})
 
-		if not self.default_price_list and doc.default_price_list:
-			self.default_price_list = doc.default_price_list
+		for field in fields:
+			if not doc.get(field): continue
+			self.update({field: doc.get(field)})
+
+		self.save()
 
 	def check_customer_group_change(self):
 		frappe.flags.customer_group_changed = False