fix: take parent cost center for child if no cost center at child (#22496)

diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index fa63ec2..8f8dafd 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -300,6 +300,11 @@
 	cost_center: function(frm) {
 		frm.events.set_child_cost_center(frm);
 	},
+
+	validate: function(frm) {
+		frm.events.set_child_cost_center(frm);
+	},
+
 	set_child_cost_center: function(frm){
 		(frm.doc.expenses || []).forEach(function(d) {
 			if (!d.cost_center){
@@ -349,9 +354,6 @@
 });
 
 frappe.ui.form.on("Expense Claim Detail", {
-	expenses_add: function(frm, cdt, cdn) {
-		frm.events.set_child_cost_center(frm);
-	},
 	amount: function(frm, cdt, cdn) {
 		var child = locals[cdt][cdn];
 		frappe.model.set_value(cdt, cdn, 'sanctioned_amount', child.amount);
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index ea469b8..5563c24 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -129,7 +129,7 @@
 					"debit": data.sanctioned_amount,
 					"debit_in_account_currency": data.sanctioned_amount,
 					"against": self.employee,
-					"cost_center": data.cost_center
+					"cost_center": data.cost_center or self.cost_center
 				}, item=data)
 			)