diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index ce4fb3f764a..36f8ce2c3b2 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -5,12 +5,12 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr from frappe import throw, _ -from frappe.model.document import Document +from frappe.utils.nestedset import NestedSet class RootNotEditable(frappe.ValidationError): pass class BalanceMismatchError(frappe.ValidationError): pass -class Account(Document): +class Account(NestedSet): nsm_parent_field = 'parent_account' def onload(self): @@ -160,26 +160,12 @@ class Account(Document): if not self.report_type: throw(_("Report Type is mandatory")) - - def update_nsm_model(self): - """update lft, rgt indices for nested set model""" - import frappe - import frappe.utils.nestedset - frappe.utils.nestedset.update_nsm(self) - - def on_update(self): - self.update_nsm_model() - - def validate_trash(self): - """checks gl entries and if child exists""" + def on_trash(self): + # checks gl entries and if child exists if self.check_gle_exists(): throw(_("Account with existing transaction can not be deleted")) - if self.check_if_child_exists(): - throw(_("Child account exists for this account. You can not delete this account.")) - def on_trash(self): - self.validate_trash() - self.update_nsm_model() + super(Account, self).on_trash() def before_rename(self, old, new, merge=False): # Add company abbr if not provided diff --git a/erpnext/setup/doctype/company/test_records.json b/erpnext/setup/doctype/company/test_records.json index 084ee2b24b5..7e26ca32074 100644 --- a/erpnext/setup/doctype/company/test_records.json +++ b/erpnext/setup/doctype/company/test_records.json @@ -6,7 +6,7 @@ "default_currency": "INR", "doctype": "Company", "domain": "Manufacturing", - "chart_of_accounts": "India - Chart of Accounts", + "chart_of_accounts": "Standard", "default_holiday_list": "_Test Holiday List" }, { @@ -16,7 +16,7 @@ "default_currency": "USD", "doctype": "Company", "domain": "Retail", - "chart_of_accounts": "India - Chart of Accounts", + "chart_of_accounts": "Standard", "default_holiday_list": "_Test Holiday List" }, { @@ -26,7 +26,7 @@ "country": "Germany", "doctype": "Company", "domain": "Retail", - "chart_of_accounts": "India - Chart of Accounts", + "chart_of_accounts": "Standard", "default_holiday_list": "_Test Holiday List" } ] diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py index a8f6a7dde5f..d77ebd16995 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -40,7 +40,7 @@ def before_tests(): "company_tagline" :"Testing", "email" :"test@erpnext.com", "password" :"test", - "chart_of_accounts" : "India - Chart of Accounts", + "chart_of_accounts" : "Standard", "domain" : "Manufacturing", })