diff --git a/erpnext/accounts/doctype/account/account.json b/erpnext/accounts/doctype/account/account.json index 9104b56c2b..28a0329e54 100644 --- a/erpnext/accounts/doctype/account/account.json +++ b/erpnext/accounts/doctype/account/account.json @@ -82,20 +82,6 @@ "permlevel": 0, "search_index": 1 }, - { - "fieldname": "root_type", - "fieldtype": "Select", - "label": "Root Type", - "options": "\nAsset\nLiability\nIncome\nExpense\nEquity", - "permlevel": 0 - }, - { - "fieldname": "report_type", - "fieldtype": "Select", - "label": "Report Type", - "options": "\nBalance Sheet\nProfit and Loss", - "permlevel": 0 - }, { "description": "Setting Account Type helps in selecting this Account in transactions.", "fieldname": "account_type", @@ -176,6 +162,22 @@ "options": "\nDebit\nCredit", "permlevel": 0 }, + { + "fieldname": "root_type", + "fieldtype": "Select", + "label": "Root Type", + "options": "\nAsset\nLiability\nIncome\nExpense\nEquity", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "report_type", + "fieldtype": "Select", + "label": "Report Type", + "options": "\nBalance Sheet\nProfit and Loss", + "permlevel": 0, + "read_only": 1 + }, { "fieldname": "lft", "fieldtype": "Int", @@ -207,7 +209,7 @@ "icon": "icon-money", "idx": 1, "in_create": 1, - "modified": "2014-05-20 11:44:53.012945", + "modified": "2014-05-21 11:42:47.255511", "modified_by": "Administrator", "module": "Accounts", "name": "Account", diff --git a/erpnext/patches/v4_0/update_account_root_type.py b/erpnext/patches/v4_0/update_account_root_type.py index c8a2e1f9cb..8b3eddfebd 100644 --- a/erpnext/patches/v4_0/update_account_root_type.py +++ b/erpnext/patches/v4_0/update_account_root_type.py @@ -9,12 +9,15 @@ def execute(): account_table_columns = frappe.db.get_table_columns("Account") if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns: - frappe.db.sql("""UPDATE tabAccount SET root_type = CASE - WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset' - WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability' - WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense' - WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income' - END""") + frappe.db.sql("""UPDATE tabAccount + SET root_type = CASE + WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset' + WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability' + WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense' + WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income' + END + WHERE ifnull(parent_account, '') = '' + """) else: frappe.db.sql("""UPDATE tabAccount @@ -24,11 +27,13 @@ def execute(): WHEN name like '%%expense%%' THEN 'Expense' WHEN name like '%%income%%' THEN 'Income' END - WHERE - ifnull(parent_account, '') = '' + WHERE ifnull(parent_account, '') = '' """) - for root in frappe.db.sql("""SELECT lft, rgt, root_type FROM `tabAccount` - WHERE ifnull(parent_account, '')=''""", as_dict=True): + for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount` + WHERE ifnull(parent_account, '')=''""", as_dict=True): + if root.root_type: frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""", (root.root_type, root.lft, root.rgt)) + else: + print "Root type not found for {0}".format(root.name)