[nested set] [minor] Added validation to test loop in hierarchy
diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py
index eded5bf..0940e1f 100644
--- a/setup/doctype/customer_group/customer_group.py
+++ b/setup/doctype/customer_group/customer_group.py
@@ -24,6 +24,7 @@
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):
diff --git a/setup/doctype/customer_group/customer_group.txt b/setup/doctype/customer_group/customer_group.txt
index 6a13500..4f9acc6 100644
--- a/setup/doctype/customer_group/customer_group.txt
+++ b/setup/doctype/customer_group/customer_group.txt
@@ -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",
diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py
index 132b829..81f6903 100644
--- a/setup/doctype/item_group/item_group.py
+++ b/setup/doctype/item_group/item_group.py
@@ -20,7 +20,6 @@
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 @@
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 \
diff --git a/setup/doctype/item_group/item_group.txt b/setup/doctype/item_group/item_group.txt
index 6e7edf9..f573110 100644
--- a/setup/doctype/item_group/item_group.txt
+++ b/setup/doctype/item_group/item_group.txt
@@ -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
},
{
diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py
index 355027b..6161706 100644
--- a/setup/doctype/sales_person/sales_person.py
+++ b/setup/doctype/sales_person/sales_person.py
@@ -21,6 +21,10 @@
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:
diff --git a/setup/doctype/sales_person/sales_person.txt b/setup/doctype/sales_person/sales_person.txt
index 56c6397..77ba6af 100644
--- a/setup/doctype/sales_person/sales_person.txt
+++ b/setup/doctype/sales_person/sales_person.txt
@@ -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",
diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py
index 742b1b4..13498fc 100644
--- a/setup/doctype/territory/territory.py
+++ b/setup/doctype/territory/territory.py
@@ -20,4 +20,7 @@
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
-
\ No newline at end of file
+
+ def on_update(self):
+ super(DocType, self).on_update()
+ self.validate_one_root()
diff --git a/setup/doctype/territory/territory.txt b/setup/doctype/territory/territory.txt
index bba7e3e..b647e7b 100644
--- a/setup/doctype/territory/territory.txt
+++ b/setup/doctype/territory/territory.txt
@@ -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",