mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 10:20:31 +00:00
[ Fixes ] v11 Tree based doctype testing (#14419)
* location tree fixes validate if child present while deleting, filter lists down only group enabled node * department tree fixes Adding child fix if added from rootnode with company filter applied. Rename consistency added. Validation added in on_trash * Company tree fix Check if child exist while deleting a node validation added. * Supplier Group tree fixes on_trash validation added if child node present * Cost Center tree fixes Adding child to root node throws error because parent_cost_center picks up root name
This commit is contained in:
@@ -82,7 +82,7 @@ class Company(NestedSet):
|
||||
frappe.throw(_("Cannot change company's default currency, because there are existing transactions. Transactions must be cancelled to change the default currency."))
|
||||
|
||||
def on_update(self):
|
||||
self.update_nsm_model()
|
||||
NestedSet.on_update(self)
|
||||
if not frappe.db.sql("""select name from tabAccount
|
||||
where company=%s and docstatus<2 limit 1""", self.name):
|
||||
if not frappe.local.flags.ignore_chart_of_accounts:
|
||||
@@ -284,14 +284,12 @@ class Company(NestedSet):
|
||||
def abbreviate(self):
|
||||
self.abbr = ''.join([c[0].upper() for c in self.company_name.split()])
|
||||
|
||||
def update_nsm_model(self):
|
||||
frappe.utils.nestedset.update_nsm(self)
|
||||
|
||||
def on_trash(self):
|
||||
"""
|
||||
Trash accounts and cost centers for this company if no gl entry exists
|
||||
"""
|
||||
self.update_nsm_model()
|
||||
NestedSet.validate_if_child_exists(self)
|
||||
frappe.utils.nestedset.update_nsm(self)
|
||||
|
||||
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
|
||||
if not rec:
|
||||
|
||||
@@ -7,17 +7,16 @@ import frappe
|
||||
from frappe.utils.nestedset import NestedSet, get_root_of
|
||||
|
||||
class SupplierGroup(NestedSet):
|
||||
nsm_parent_field = 'parent_supplier_group';
|
||||
nsm_parent_field = 'parent_supplier_group'
|
||||
|
||||
def validate(self):
|
||||
if not self.parent_supplier_group:
|
||||
self.parent_supplier_group = get_root_of("Supplier Group")
|
||||
|
||||
def update_nsm_model(self):
|
||||
frappe.utils.nestedset.update_nsm(self)
|
||||
|
||||
def on_update(self):
|
||||
self.update_nsm_model()
|
||||
NestedSet.on_update(self)
|
||||
self.validate_one_root()
|
||||
|
||||
def on_trash(self):
|
||||
self.update_nsm_model()
|
||||
NestedSet.validate_if_child_exists(self)
|
||||
frappe.utils.nestedset.update_nsm(self)
|
||||
|
||||
Reference in New Issue
Block a user