From 24e136e3f37bf94530955b804e5442425a39955b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 11 Mar 2014 17:57:38 +0530 Subject: [PATCH] Patch: set root_type for old existing accounts --- erpnext/patches.txt | 1 - erpnext/patches/4_0/countrywise_coa.py | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index a9ae54877f..c1f43e38a7 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -28,6 +28,5 @@ execute:frappe.db.sql("""delete from `tabWebsite Item Group` where ifnull(item_g erpnext.patches.4_0.remove_module_home_pages erpnext.patches.4_0.split_email_settings erpnext.patches.4_0.fix_employee_user_id -erpnext.patches.4_0.set_account_details erpnext.patches.4_0.import_country_codes execute:patches.4_0.countrywise_coa diff --git a/erpnext/patches/4_0/countrywise_coa.py b/erpnext/patches/4_0/countrywise_coa.py index f2e0acf9d9..7bf4b26d8b 100644 --- a/erpnext/patches/4_0/countrywise_coa.py +++ b/erpnext/patches/4_0/countrywise_coa.py @@ -5,5 +5,16 @@ from __future__ import unicode_literals import frappe def execute(): + frappe.reload_doc("setup", 'doctype', "company") + frappe.reload_doc("accounts", 'doctype', "account") + frappe.db.sql("""update tabAccount set account_type='Fixed Asset' - where account_type='Fixed Asset Account'""") \ No newline at end of file + where account_type='Fixed Asset Account'""") + + for d in (('Asset', 'Debit', 'No'), ('Liability', 'Credit', 'No'), ('Expense', 'Debit', 'Yes'), + ('Income', 'Credit', 'Yes')): + frappe.db.sql("""update `tabAccount` set root_type = %s + where debit_or_credit=%s and is_pl_account=%s""", d) + + frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit + where ifnull(allow_negative_balance, 0) = 0""") \ No newline at end of file