From ee442dc104bc2bf2877b6320985baaf2079a0c95 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 5 Oct 2012 14:32:36 +0530 Subject: [PATCH] update account property as per root --- patches/october_2012/update_account_property.py | 14 ++++++++++++++ patches/patch_list.py | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 patches/october_2012/update_account_property.py diff --git a/patches/october_2012/update_account_property.py b/patches/october_2012/update_account_property.py new file mode 100644 index 0000000000..d30f0ccafe --- /dev/null +++ b/patches/october_2012/update_account_property.py @@ -0,0 +1,14 @@ +def execute(): + import webnotes + from webnotes.utils.nestedset import rebuild_tree + rebuild_tree('Account', 'parent_account') + + roots = webnotes.conn.sql(""" + select lft, rgt, debit_or_credit, is_pl_account, company from `tabAccount` + where ifnull(parent_account, '') = '' + """, as_dict=1) + + for acc in roots: + webnotes.conn.sql("""update tabAccount set debit_or_credit = %(debit_or_credit)s, + is_pl_account = %(is_pl_account)s, company = %(company)s + where lft > %(lft)s and rgt < %(rgt)s""", acc, debug=1) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index f750ac06f5..fc2582a4f4 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -623,4 +623,8 @@ patch_list = [ 'patch_module': 'patches.october_2012', 'patch_file': 'remove_old_customer_contact_address', }, + { + 'patch_module': 'patches.october_2012', + 'patch_file': 'update_account_property', + }, ]