fix: chart of accounts field toggling improv
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 5592e9b..aff4baf 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -17,8 +17,6 @@
}
});
- frm.set_df_property("create_chart_of_accounts_based_on", "read_only", frm.doc.parent_company ? 1 : 0);
- frm.set_df_property("existing_company", "read_only", frm.doc.parent_company ? 1 : 0);
frm.set_query("parent_company", function() {
return {
filters: {"is_group": 1}
@@ -37,9 +35,10 @@
},
parent_company: function(frm) {
- if(!frm.doc.parent_company) return;
- frm.set_value("create_chart_of_accounts_based_on", "Existing Company");
- frm.set_value("existing_company", frm.doc.parent_company);
+ var bool = frm.doc.parent_company ? true : false;
+ frm.set_value('create_chart_of_accounts_based_on', bool ? "Existing Company" : "");
+ frm.set_value('existing_company', bool ? frm.doc.parent_company : "");
+ disbale_coa_fields(frm, bool);
},
date_of_commencement: function(frm) {
@@ -54,8 +53,9 @@
refresh: function(frm) {
if(!frm.doc.__islocal) {
- frm.set_df_property("abbr", "read_only", 1);
+ frm.doc.abbr && frm.set_df_property("abbr", "read_only", 1);
frm.set_df_property("parent_company", "read_only", 1);
+ disbale_coa_fields(frm);
}
frm.toggle_display('address_html', !frm.doc.__islocal);
@@ -271,3 +271,9 @@
}
});
}
+
+var disbale_coa_fields = function(frm, bool=true) {
+ frm.set_df_property("create_chart_of_accounts_based_on", "read_only", bool);
+ frm.set_df_property("chart_of_accounts", "read_only", bool);
+ frm.set_df_property("existing_company", "read_only", bool);
+};
\ No newline at end of file