update account root type patch
This commit is contained in:
parent
4efc5d74d4
commit
27b12ef1b6
@ -82,20 +82,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"search_index": 1
|
"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.",
|
"description": "Setting Account Type helps in selecting this Account in transactions.",
|
||||||
"fieldname": "account_type",
|
"fieldname": "account_type",
|
||||||
@ -176,6 +162,22 @@
|
|||||||
"options": "\nDebit\nCredit",
|
"options": "\nDebit\nCredit",
|
||||||
"permlevel": 0
|
"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",
|
"fieldname": "lft",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
@ -207,7 +209,7 @@
|
|||||||
"icon": "icon-money",
|
"icon": "icon-money",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"modified": "2014-05-20 11:44:53.012945",
|
"modified": "2014-05-21 11:42:47.255511",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Account",
|
"name": "Account",
|
||||||
|
@ -9,12 +9,15 @@ def execute():
|
|||||||
|
|
||||||
account_table_columns = frappe.db.get_table_columns("Account")
|
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:
|
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
|
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='Debit' and is_pl_account = 'No') THEN 'Asset'
|
||||||
WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability'
|
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='Debit' and is_pl_account = 'Yes') THEN 'Expense'
|
||||||
WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income'
|
WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income'
|
||||||
END""")
|
END
|
||||||
|
WHERE ifnull(parent_account, '') = ''
|
||||||
|
""")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
frappe.db.sql("""UPDATE tabAccount
|
frappe.db.sql("""UPDATE tabAccount
|
||||||
@ -24,11 +27,13 @@ def execute():
|
|||||||
WHEN name like '%%expense%%' THEN 'Expense'
|
WHEN name like '%%expense%%' THEN 'Expense'
|
||||||
WHEN name like '%%income%%' THEN 'Income'
|
WHEN name like '%%income%%' THEN 'Income'
|
||||||
END
|
END
|
||||||
WHERE
|
WHERE ifnull(parent_account, '') = ''
|
||||||
ifnull(parent_account, '') = ''
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
for root in frappe.db.sql("""SELECT lft, rgt, root_type FROM `tabAccount`
|
for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount`
|
||||||
WHERE ifnull(parent_account, '')=''""", as_dict=True):
|
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""",
|
frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""",
|
||||||
(root.root_type, root.lft, root.rgt))
|
(root.root_type, root.lft, root.rgt))
|
||||||
|
else:
|
||||||
|
print "Root type not found for {0}".format(root.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user