Merge pull request #40886 from nabinhait/permission-issue

fix: Ignore permissions while fetching module settings properties
diff --git a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.json b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.json
index c7c5926..bd206e1 100644
--- a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.json
+++ b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.json
@@ -35,10 +35,11 @@
   }
  ],
  "links": [],
- "modified": "2024-03-27 13:10:11.676098",
+ "modified": "2024-04-07 11:26:42.021585",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Payment Terms Template",
+ "naming_rule": "By fieldname",
  "owner": "Administrator",
  "permissions": [
   {
@@ -76,6 +77,15 @@
    "role": "Accounts Manager",
    "share": 1,
    "write": 1
+  },
+  {
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "report": 1,
+   "role": "All",
+   "select": 1,
+   "share": 1
   }
  ],
  "sort_field": "creation",
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 21b9186..22957b6 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -1100,6 +1100,11 @@
 				row["tax_amount"] = flt(row["tax_amount"], precision)
 
 
+@frappe.whitelist()
+def get_rounding_tax_settings():
+	return frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax")
+
+
 class init_landed_taxes_and_totals:
 	def __init__(self, doc):
 		self.doc = doc
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 0d272b8..f824e65 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -210,10 +210,12 @@
 			});
 		}
 
-		frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax")
-			.then((round_row_wise_tax) => {
-				frappe.flags.round_row_wise_tax = round_row_wise_tax;
-			})
+		frappe.call({
+			method: "erpnext.controllers.taxes_and_totals.get_rounding_tax_settings",
+			callback: function(r) {
+				frappe.flags.round_off_settings = r.message;
+			}
+		});
 	}
 
 	determine_exclusive_rate() {
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 08e3940..261d557 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -252,9 +252,14 @@
 	}
 
 	toggle_enable_for_stock_uom(field) {
-		frappe.db.get_single_value('Stock Settings', field)
-		.then(value => {
-			this.frm.fields_dict["items"].grid.toggle_enable("stock_qty", value);
+		frappe.call({
+			method: 'erpnext.stock.doctype.stock_settings.stock_settings.get_enable_stock_uom_editing',
+			callback: (r) => {
+				if (r.message) {
+					var value = r.message[field];
+					this.frm.fields_dict["items"].grid.toggle_enable("stock_qty", value);
+				}
+			}
 		});
 	}
 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 715d4d1..69bbae3 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -111,16 +111,26 @@
 			}
 
 			if (frm.doc.docstatus === 0) {
-				frappe.db.get_single_value("Stock Settings", "enable_stock_reservation").then((value) => {
-					if (!value) {
-						// If `Stock Reservation` is disabled in Stock Settings, set Reserve Stock to 0 and make the field read-only and hidden.
-						frm.set_value("reserve_stock", 0);
-						frm.set_df_property("reserve_stock", "read_only", 1);
-						frm.set_df_property("reserve_stock", "hidden", 1);
-						frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "hidden", 1);
-						frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "default", 0);
-						frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "read_only", 1);
-					}
+				frappe.call({
+					method: "erpnext.selling.doctype.sales_order.sales_order.get_stock_reservation_status",
+					callback: function (r) {
+						if (!r.message) {
+							frm.set_value("reserve_stock", 0);
+							frm.set_df_property("reserve_stock", "read_only", 1);
+							frm.set_df_property("reserve_stock", "hidden", 1);
+							frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "hidden", 1);
+							frm.fields_dict.items.grid.update_docfield_property(
+								"reserve_stock",
+								"default",
+								0
+							);
+							frm.fields_dict.items.grid.update_docfield_property(
+								"reserve_stock",
+								"read_only",
+								1
+							);
+						}
+					},
 				});
 			}
 		}
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 4b8ff13..298fd4b 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -1724,3 +1724,8 @@
 					)
 
 		return items
+
+
+@frappe.whitelist()
+def get_stock_reservation_status():
+	return frappe.db.get_single_value("Stock Settings", "enable_stock_reservation")
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py
index 7fcda1d..b5df094 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.py
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.py
@@ -308,3 +308,13 @@
 			clean_description = clean_html(item.description)
 		if item.description != clean_description:
 			frappe.db.set_value("Item", item.name, "description", clean_description)
+
+
+@frappe.whitelist()
+def get_enable_stock_uom_editing():
+	return frappe.get_cached_value(
+		"Stock Settings",
+		None,
+		["allow_to_edit_stock_uom_qty_for_sales", "allow_to_edit_stock_uom_qty_for_purchase"],
+		as_dict=1,
+	)