From 1a4bfdd090c0c5f73bde90f81d3783d2b7d0a4c7 Mon Sep 17 00:00:00 2001 From: Zlash65 Date: Mon, 28 Jan 2019 16:35:41 +0530 Subject: [PATCH] feat: selecting parent_company should disable chart_of_accounts based fields --- erpnext/setup/doctype/company/company.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 70e047a4e80..dbfbc5932ea 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -16,6 +16,14 @@ frappe.ui.form.on("Company", { filters: {"is_additional_component": 1} } }); + + 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} + } + }); }, company_name: function(frm) { @@ -28,6 +36,12 @@ frappe.ui.form.on("Company", { } }, + 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); + }, + date_of_commencement: function(frm) { if(frm.doc.date_of_commencement