rebuild account tree before reposting acocunt balance
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
index a44b756..ce7140a 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
@@ -44,6 +44,7 @@
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 @@
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))