[nested set] [minor] Added validation to test loop in hierarchy

This commit is contained in:
Rushabh Mehta 2013-08-05 18:14:39 +05:30
parent d056e1b453
commit a1d668a6e3
8 changed files with 19 additions and 10 deletions

View File

@ -24,6 +24,7 @@ class DocType(DocTypeNestedSet):
def on_update(self):
self.validate_name_with_customer()
super(DocType, self).on_update()
self.validate_one_root()
def validate_name_with_customer(self):
if webnotes.conn.exists("Customer", self.doc.name):

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:23",
"docstatus": 0,
"modified": "2013-07-05 14:34:20",
"modified": "2013-08-05 18:12:57",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -69,7 +69,7 @@
"oldfieldname": "parent_customer_group",
"oldfieldtype": "Link",
"options": "Customer Group",
"reqd": 1
"reqd": 0
},
{
"description": "Only leaf nodes are allowed in transaction",

View File

@ -20,7 +20,6 @@ class DocType(DocTypeNestedSet):
from website.helpers.product import invalidate_cache_for
if self.doc.show_in_website:
from webnotes.webutils import update_page_name
# webpage updates
@ -38,6 +37,8 @@ class DocType(DocTypeNestedSet):
webnotes.conn.set(self.doc, "page_name", None)
self.validate_one_root()
def validate_name_with_item(self):
if webnotes.conn.exists("Item", self.doc.name):
webnotes.msgprint("An item exists with same name (%s), please change the \

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:29",
"docstatus": 0,
"modified": "2013-07-23 12:00:14",
"modified": "2013-08-05 17:21:14",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -75,7 +75,7 @@
"oldfieldname": "parent_item_group",
"oldfieldtype": "Link",
"options": "Item Group",
"reqd": 1,
"reqd": 0,
"search_index": 0
},
{

View File

@ -21,6 +21,10 @@ class DocType(DocTypeNestedSet):
webnotes.msgprint("Either target qty or target amount is mandatory.")
raise Exception
def on_update(self):
super(DocType, self).on_update()
self.validate_one_root()
def get_email_id(self):
profile = webnotes.conn.get_value("Employee", self.doc.employee, "user_id")
if not profile:

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
"modified": "2013-07-10 12:51:58",
"modified": "2013-08-05 18:11:22",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -69,7 +69,7 @@
"oldfieldname": "parent_sales_person",
"oldfieldtype": "Link",
"options": "Sales Person",
"reqd": 1
"reqd": 0
},
{
"doctype": "DocField",

View File

@ -20,4 +20,7 @@ class DocType(DocTypeNestedSet):
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
def on_update(self):
super(DocType, self).on_update()
self.validate_one_root()

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
"modified": "2013-07-05 14:58:15",
"modified": "2013-08-05 18:12:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -71,7 +71,7 @@
"oldfieldname": "parent_territory",
"oldfieldtype": "Link",
"options": "Territory",
"reqd": 1
"reqd": 0
},
{
"description": "Only leaf nodes are allowed in transaction",