Merge pull request #40081 from rohitwaghchaure/fixed-10401

fix: Cannot read properties of undefined
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 68bcafc..aee761f 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -40,7 +40,10 @@
 
 	is_perpetual_inventory_enabled: function(company) {
 		if(company) {
-			return frappe.get_doc(":Company", company).enable_perpetual_inventory
+			let company_local = locals[":Company"] && locals[":Company"][company];
+			if(company_local) {
+				return cint(company_local.enable_perpetual_inventory);
+			}
 		}
 	},