diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 222682eb8c..ec906f8798 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -232,7 +232,7 @@ erpnext.AccountsChart = Class.extend({ $(fd.tax_rate.wrapper).toggle(false); $(fd.warehouse.wrapper).toggle(false); } else { - $(fd.account_type.wrapper).toggle(true); + $(fd.account_type.wrapper).toggle(node.root ? false : true); fd.account_type.$input.trigger("change"); } }); @@ -243,9 +243,6 @@ erpnext.AccountsChart = Class.extend({ $(fd.warehouse.wrapper).toggle(fd.account_type.get_value()==='Warehouse'); }) - // root type if root - $(fd.root_type.wrapper).toggle(node.root); - // create d.set_primary_action(__("Create New"), function() { var btn = this; @@ -262,10 +259,10 @@ erpnext.AccountsChart = Class.extend({ v.company = me.company; if(node.root) { - v.is_root = true; + v.is_root = 1; v.parent_account = null; } else { - v.is_root = false; + v.is_root = 0; v.root_type = null; } @@ -289,6 +286,11 @@ erpnext.AccountsChart = Class.extend({ } $(fd.is_group.input).prop("checked", false).change(); + + // In case of root, show root type and hide account_type, is_group + $(fd.root_type.wrapper).toggle(node.root); + $(fd.is_group.wrapper).toggle(!node.root); + d.show(); }, diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 48668fa679..077fcb4599 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.utils import nowdate, cstr, flt, now, getdate, add_months +from frappe.utils import nowdate, cstr, flt, cint, now, getdate, add_months from frappe import throw, _ from frappe.utils import formatdate import frappe.desk.reportview @@ -129,12 +129,13 @@ def add_ac(args=None): if not args: args = frappe.local.form_dict args.pop("cmd") - + ac = frappe.new_doc("Account") ac.update(args) ac.old_parent = "" ac.freeze_account = "No" - if ac.get("is_root"): + if cint(ac.get("is_root")): + ac.parent_account = None ac.flags.ignore_mandatory = True ac.insert()