From 266ee64dc7394805547f545d01095b277742e4b8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 14 Sep 2012 10:17:46 +0530 Subject: [PATCH] rebuild account tree before reposting acocunt balance --- erpnext/accounts/doctype/fiscal_year/fiscal_year.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index a44b75670c..ce7140aa78 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -44,6 +44,7 @@ class DocType: if not in_transaction: sql("start transaction") + self.rebuid_account_tree() self.clear_account_balances() self.create_account_balances() self.update_opening(self.doc.company) @@ -51,7 +52,11 @@ class DocType: sql("commit") msgprint("Account balance reposted for fiscal year: " + self.doc.name) - + + def rebuid_account_tree(self): + from webnotes.utils.nestedset import rebuild_tree + rebuild_tree('Account', 'parent_account') + def clear_account_balances(self): # balances clear - `tabAccount Balance` for fiscal year sql("update `tabAccount Balance` t1, tabAccount t2 set t1.opening=0, t1.balance=0, t1.debit=0, t1.credit=0 where t1.fiscal_year=%s and t2.company = %s and t1.account = t2.name", (self.doc.name, self.doc.company))