Merge pull request #11417 from rohitwaghchaure/issue_not_save_v9

[Fix] Customer is manadatory even if customer has selected in the Issue
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 17ac1f7..52d8a2d 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -648,13 +648,13 @@
 
 	set_difference_amount: function(frm) {
 		var unallocated_amount = 0;
+		var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
+			function(d) { return flt(d.amount) }));
+
 		if(frm.doc.party) {
 			var party_amount = frm.doc.payment_type=="Receive" ?
 				frm.doc.paid_amount : frm.doc.received_amount;
 
-			var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
-				function(d) { return flt(d.amount) }));
-
 			if(frm.doc.total_allocated_amount < party_amount) {
 				if(frm.doc.payment_type == "Receive") {
 					unallocated_amount = party_amount - (frm.doc.total_allocated_amount - total_deductions);
diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py
index 686fe8d..8efbed8 100644
--- a/erpnext/hub_node/__init__.py
+++ b/erpnext/hub_node/__init__.py
@@ -34,7 +34,9 @@
 	return response
 
 @frappe.whitelist()
-def get_item_details(hub_sync_id):
+def get_item_details(hub_sync_id=None):
+	if not hub_sync_id:
+		return
 	connection = get_connection()
 	return connection.get_doc('Hub Item', hub_sync_id)
 
diff --git a/erpnext/hub_node/page/hub/hub.js b/erpnext/hub_node/page/hub/hub.js
index 143f554..297a4d1 100644
--- a/erpnext/hub_node/page/hub/hub.js
+++ b/erpnext/hub_node/page/hub/hub.js
@@ -382,6 +382,7 @@
 			},
 			method: "erpnext.hub_node.get_item_details",
 			callback: (r) => {
+				if (!r || !r.message) return;
 				let item = r.message;
 				this.item_cache[item_code] = item;
 				this.render_item_page(item);
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index fa21a3d..747a3c0 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -477,9 +477,11 @@
 		target.qty = flt(source.qty) - flt(source.delivered_qty)
 
 		item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
-		target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
-			or item.selling_cost_center \
-			or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
+
+		if item:
+			target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
+				or item.selling_cost_center \
+				or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
 
 	target_doc = get_mapped_doc("Sales Order", source_name, {
 		"Sales Order": {