Minor fixes related to account renaming and deletion
This commit is contained in:
parent
a5ebebd09c
commit
1749b7c16b
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
|
@ -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",
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user