From 75999a7ae4d62927687a3448a9e2cd0e331d9210 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Wed, 10 Dec 2025 00:38:33 +0530 Subject: [PATCH] fix: make amount and percent field read only when distribute equally is enabled --- erpnext/accounts/doctype/budget/budget.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/erpnext/accounts/doctype/budget/budget.js b/erpnext/accounts/doctype/budget/budget.js index 3ac7b8fe8f8..968700ede4c 100644 --- a/erpnext/accounts/doctype/budget/budget.js +++ b/erpnext/accounts/doctype/budget/budget.js @@ -42,6 +42,8 @@ frappe.ui.form.on("Budget", { ); } } + + toggle_distribution_fields(frm); }, budget_against: function (frm) { @@ -58,6 +60,12 @@ frappe.ui.form.on("Budget", { } }, + distribute_equally: function (frm) { + console.log("here"); + + toggle_distribution_fields(frm); + }, + set_null_value: function (frm) { if (frm.doc.budget_against == "Cost Center") { frm.set_value("project", null); @@ -111,3 +119,13 @@ frappe.ui.form.on("Budget Distribution", { } }, }); + +function toggle_distribution_fields(frm) { + const grid = frm.fields_dict.budget_distribution.grid; + + ["amount", "percent"].forEach((field) => { + grid.update_docfield_property(field, "read_only", frm.doc.distribute_equally); + }); + + grid.refresh(); +}