Merge branch 'latest' of github.com:webnotes/erpnext into latest

This commit is contained in:
Rushabh Mehta 2012-02-20 08:35:47 +01:00
commit cb1ab98bec

View File

@ -203,7 +203,6 @@ class DocType:
# Add curret year balance
self.set_year_balance()
# Check user role for approval process
# ==================================================================
def get_authorized_user(self):
@ -232,7 +231,7 @@ class DocType:
# ==================================================================
def check_balance_before_trash(self):
if self.check_gle_exists():
msgprint("Account with existing transaction can not be trashed", raise_exception=1)
msgprint("Account with existing transaction (Sales Invoice / Purchase Invoice / Journal Voucher) can not be trashed", raise_exception=1)
if self.check_if_child_exists():
msgprint("Child account exists for this account. You can not trash this account.", raise_exception=1)
@ -248,10 +247,14 @@ class DocType:
def on_trash(self):
# Check balance before trash
self.check_balance_before_trash()
# rebuild tree
set(self.doc,'old_parent', '')
self.update_nsm_model()
# delete all cancelled gl entry of this account
sql("delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'", self.doc.name)
#delete Account Balance
sql("delete from `tabAccount Balance` where account = %s", self.doc.name)
@ -260,6 +263,8 @@ class DocType:
def on_restore(self):
# rebuild tree
self.update_nsm_model()
# intiate balances
self.set_year_balance()
# on rename
# ---------