Merge pull request #17006 from deepeshgarg007/account-fix

fix: Ignore root company validation setting in company master
This commit is contained in:
Nabin Hait 2019-03-26 17:49:21 +05:30 committed by GitHub
commit 411f66a177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 135 additions and 4 deletions

View File

@ -98,6 +98,8 @@ class Account(NestedSet):
ancestors = get_root_company(self.company)
if ancestors:
if frappe.get_value("Company", self.company, "allow_account_creation_against_child_company"):
return
frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0]))
else:
descendants = get_descendants_of('Company', self.company)

View File

@ -23,6 +23,10 @@ frappe.treeview_settings["Account"] = {
if(r.message) {
let root_company = r.message.length ? r.message[0] : "";
me.page.fields_dict.root_company.set_value(root_company);
frappe.db.get_value("Company", {"name": company}, "allow_account_creation_against_child_company", (r) => {
frappe.flags.ignore_root_company_validation = r.allow_account_creation_against_child_company;
});
}
}
});
@ -133,9 +137,10 @@ frappe.treeview_settings["Account"] = {
{
label:__("Add Child"),
condition: function(node) {
return frappe.boot.user.can_create.indexOf("Account") !== -1 &&
!frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value() &&
node.expandable && !node.hide_add;
return frappe.boot.user.can_create.indexOf("Account") !== -1
&& (!frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value()
|| frappe.flags.ignore_root_company_validation)
&& node.expandable && !node.hide_add;
},
click: function() {
var me = frappe.treeview_settings['Account'].treeview;

View File

@ -22,6 +22,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "details",
"fieldtype": "Section Break",
"hidden": 0,
@ -54,6 +55,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "company_name",
"fieldtype": "Data",
"hidden": 0,
@ -88,6 +90,7 @@
"collapsible": 0,
"columns": 0,
"description": "",
"fetch_if_empty": 0,
"fieldname": "abbr",
"fieldtype": "Data",
"hidden": 0,
@ -122,6 +125,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal && in_list(frappe.user_roles, \"System Manager\")",
"fetch_if_empty": 0,
"fieldname": "change_abbr",
"fieldtype": "Button",
"hidden": 0,
@ -153,6 +157,7 @@
"bold": 1,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "is_group",
"fieldtype": "Check",
"hidden": 0,
@ -185,6 +190,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_finance_book",
"fieldtype": "Link",
"hidden": 0,
@ -218,6 +224,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "cb0",
"fieldtype": "Column Break",
"hidden": 0,
@ -248,6 +255,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "domain",
"fieldtype": "Link",
"hidden": 0,
@ -280,6 +288,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "parent_company",
"fieldtype": "Link",
"hidden": 0,
@ -313,6 +322,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sb_about",
"fieldtype": "Section Break",
"hidden": 0,
@ -345,6 +355,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "company_logo",
"fieldtype": "Attach Image",
"hidden": 0,
@ -377,6 +388,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "company_description",
"fieldtype": "Text Editor",
"hidden": 0,
@ -409,6 +421,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sales_settings",
"fieldtype": "Section Break",
"hidden": 0,
@ -441,6 +454,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sales_monthly_history",
"fieldtype": "Small Text",
"hidden": 1,
@ -473,6 +487,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "transactions_annual_history",
"fieldtype": "Code",
"hidden": 1,
@ -505,6 +520,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "monthly_sales_target",
"fieldtype": "Currency",
"hidden": 0,
@ -538,6 +554,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_goals",
"fieldtype": "Column Break",
"hidden": 0,
@ -569,6 +586,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "total_monthly_sales",
"fieldtype": "Currency",
"hidden": 0,
@ -602,6 +620,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "charts_section",
"fieldtype": "Section Break",
"hidden": 0,
@ -633,6 +652,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_currency",
"fieldtype": "Link",
"hidden": 0,
@ -665,6 +685,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_letter_head",
"fieldtype": "Link",
"hidden": 0,
@ -698,6 +719,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_holiday_list",
"fieldtype": "Link",
"hidden": 0,
@ -731,6 +753,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "standard_working_hours",
"fieldtype": "Float",
"hidden": 0,
@ -763,6 +786,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_terms",
"fieldtype": "Link",
"hidden": 0,
@ -795,6 +819,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_10",
"fieldtype": "Column Break",
"hidden": 0,
@ -826,6 +851,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "country",
"fieldtype": "Link",
"hidden": 0,
@ -858,6 +884,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "create_chart_of_accounts_based_on",
"fieldtype": "Select",
"hidden": 0,
@ -892,6 +919,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.create_chart_of_accounts_based_on===\"Standard Template\"",
"fetch_if_empty": 0,
"fieldname": "chart_of_accounts",
"fieldtype": "Select",
"hidden": 0,
@ -926,6 +954,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.create_chart_of_accounts_based_on===\"Existing Company\"",
"fetch_if_empty": 0,
"fieldname": "existing_company",
"fieldtype": "Link",
"hidden": 0,
@ -959,6 +988,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "tax_id",
"fieldtype": "Data",
"hidden": 0,
@ -991,6 +1021,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "date_of_establishment",
"fieldtype": "Date",
"hidden": 0,
@ -1023,6 +1054,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_settings",
"fieldtype": "Section Break",
"hidden": 0,
@ -1056,6 +1088,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_bank_account",
"fieldtype": "Link",
"hidden": 0,
@ -1091,6 +1124,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_cash_account",
"fieldtype": "Link",
"hidden": 0,
@ -1124,6 +1158,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_receivable_account",
"fieldtype": "Link",
"hidden": 0,
@ -1158,6 +1193,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "round_off_account",
"fieldtype": "Link",
"hidden": 0,
@ -1191,6 +1227,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "round_off_cost_center",
"fieldtype": "Link",
"hidden": 0,
@ -1224,6 +1261,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "write_off_account",
"fieldtype": "Link",
"hidden": 0,
@ -1257,6 +1295,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "discount_allowed_account",
"fieldtype": "Link",
"hidden": 0,
@ -1290,6 +1329,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "discount_received_account",
"fieldtype": "Link",
"hidden": 0,
@ -1323,6 +1363,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "exchange_gain_loss_account",
"fieldtype": "Link",
"hidden": 0,
@ -1356,6 +1397,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "unrealized_exchange_gain_loss_account",
"fieldtype": "Link",
"hidden": 0,
@ -1389,6 +1431,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break0",
"fieldtype": "Column Break",
"hidden": 0,
@ -1414,6 +1457,40 @@
"unique": 0,
"width": "50%"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.parent_company",
"fetch_if_empty": 0,
"fieldname": "allow_account_creation_against_child_company",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Allow Account Creation Against Child Company",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -1422,6 +1499,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_payable_account",
"fieldtype": "Link",
"hidden": 0,
@ -1456,6 +1534,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_employee_advance_account",
"fieldtype": "Link",
"hidden": 0,
@ -1490,6 +1569,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_expense_account",
"fieldtype": "Link",
"hidden": 0,
@ -1523,6 +1603,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_income_account",
"fieldtype": "Link",
"hidden": 0,
@ -1556,6 +1637,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_deferred_revenue_account",
"fieldtype": "Link",
"hidden": 0,
@ -1590,6 +1672,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_deferred_expense_account",
"fieldtype": "Link",
"hidden": 0,
@ -1624,6 +1707,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_payroll_payable_account",
"fieldtype": "Link",
"hidden": 0,
@ -1658,6 +1742,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "default_expense_claim_payable_account",
"fieldtype": "Link",
"hidden": 0,
@ -1691,6 +1776,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_22",
"fieldtype": "Section Break",
"hidden": 0,
@ -1723,6 +1809,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@ -1755,6 +1842,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_26",
"fieldtype": "Column Break",
"hidden": 0,
@ -1787,6 +1875,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "credit_limit",
"fieldtype": "Currency",
"hidden": 0,
@ -1822,6 +1911,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_if_empty": 0,
"fieldname": "payment_terms",
"fieldtype": "Link",
"hidden": 0,
@ -1856,6 +1946,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fetch_if_empty": 0,
"fieldname": "auto_accounting_for_stock_settings",
"fieldtype": "Section Break",
"hidden": 0,
@ -1888,6 +1979,7 @@
"collapsible": 0,
"columns": 0,
"default": "1",
"fetch_if_empty": 0,
"fieldname": "enable_perpetual_inventory",
"fieldtype": "Check",
"hidden": 0,
@ -1920,6 +2012,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "default_inventory_account",
"fieldtype": "Link",
"hidden": 0,
@ -1953,6 +2046,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "stock_adjustment_account",
"fieldtype": "Link",
"hidden": 0,
@ -1985,6 +2079,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_32",
"fieldtype": "Column Break",
"hidden": 0,
@ -2016,6 +2111,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "stock_received_but_not_billed",
"fieldtype": "Link",
"hidden": 0,
@ -2048,6 +2144,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "expenses_included_in_valuation",
"fieldtype": "Link",
"hidden": 0,
@ -2080,6 +2177,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "fixed_asset_depreciation_settings",
"fieldtype": "Section Break",
"hidden": 0,
@ -2112,6 +2210,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "accumulated_depreciation_account",
"fieldtype": "Link",
"hidden": 0,
@ -2145,6 +2244,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "depreciation_expense_account",
"fieldtype": "Link",
"hidden": 0,
@ -2178,6 +2278,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "series_for_depreciation_entry",
"fieldtype": "Data",
"hidden": 0,
@ -2210,6 +2311,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "expenses_included_in_asset_valuation",
"fieldtype": "Link",
"hidden": 0,
@ -2243,6 +2345,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_40",
"fieldtype": "Column Break",
"hidden": 0,
@ -2274,6 +2377,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "disposal_account",
"fieldtype": "Link",
"hidden": 0,
@ -2307,6 +2411,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "depreciation_cost_center",
"fieldtype": "Link",
"hidden": 0,
@ -2340,6 +2445,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "capital_work_in_progress_account",
"fieldtype": "Link",
"hidden": 0,
@ -2373,6 +2479,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "asset_received_but_not_billed",
"fieldtype": "Link",
"hidden": 0,
@ -2406,6 +2513,7 @@
"bold": 0,
"collapsible": 1,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "budget_detail",
"fieldtype": "Section Break",
"hidden": 0,
@ -2438,6 +2546,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "exception_budget_approver_role",
"fieldtype": "Link",
"hidden": 0,
@ -2472,6 +2581,7 @@
"collapsible": 0,
"columns": 0,
"description": "For reference only.",
"fetch_if_empty": 0,
"fieldname": "company_info",
"fieldtype": "Section Break",
"hidden": 0,
@ -2503,6 +2613,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "date_of_incorporation",
"fieldtype": "Date",
"hidden": 0,
@ -2535,6 +2646,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "address_html",
"fieldtype": "HTML",
"hidden": 0,
@ -2566,6 +2678,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break1",
"fieldtype": "Column Break",
"hidden": 0,
@ -2599,6 +2712,7 @@
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.date_of_incorporation",
"fetch_if_empty": 0,
"fieldname": "date_of_commencement",
"fieldtype": "Date",
"hidden": 0,
@ -2631,6 +2745,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "phone_no",
"fieldtype": "Data",
"hidden": 0,
@ -2665,6 +2780,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "fax",
"fieldtype": "Data",
"hidden": 0,
@ -2699,6 +2815,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "email",
"fieldtype": "Data",
"hidden": 0,
@ -2733,6 +2850,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "website",
"fieldtype": "Data",
"hidden": 0,
@ -2767,6 +2885,7 @@
"collapsible": 0,
"columns": 0,
"description": "",
"fetch_if_empty": 0,
"fieldname": "registration_info",
"fieldtype": "Section Break",
"hidden": 0,
@ -2801,6 +2920,7 @@
"collapsible": 0,
"columns": 0,
"description": "Company registration numbers for your reference. Tax numbers etc.",
"fetch_if_empty": 0,
"fieldname": "registration_details",
"fieldtype": "Code",
"hidden": 0,
@ -2834,6 +2954,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "delete_company_transactions",
"fieldtype": "Button",
"hidden": 0,
@ -2866,6 +2987,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
@ -2898,6 +3020,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt",
"fieldtype": "Int",
"hidden": 1,
@ -2930,6 +3053,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "old_parent",
"fieldtype": "Data",
"hidden": 1,
@ -2969,7 +3093,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2019-01-15 13:29:54.510379",
"modified": "2019-03-26 17:15:50.390548",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",