Fixes and Validations for nested doctypes

This commit is contained in:
Anand Doshi
2012-09-24 14:00:59 +05:30
parent 473f7d6314
commit 1fc9ae2230
6 changed files with 41 additions and 22 deletions

View File

@@ -174,7 +174,7 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({
me.parent_map = {};
me.item_by_name = {};
me.data = [];
$.each(items, function(i, v) {
var d = copy_dict(v);

View File

@@ -23,7 +23,17 @@ cur_frm.cscript.set_breadcrumbs = function(barea) {
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc);
}
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root customer group
if(doc.name==='All Customer Groups') {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root customer group and cannot be edited.");
} else {
cur_frm.set_intro(null);
}
}
//get query select Customer Group

View File

@@ -32,32 +32,18 @@ in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
from webnotes.utils.nestedset import DocTypeNestedSet
class DocType(DocTypeNestedSet):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.nsm_parent_field = 'parent_customer_group';
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
def validate(self):
if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
msgprint("""Another %s record is trashed.
To untrash please go to Setup & click on Trash."""%(self.doc.customer_group_name), raise_exception = 1)
self.validate_root_details("All Customer Groups", "parent_customer_group")
def on_trash(self):
cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name)
@@ -72,4 +58,4 @@ class DocType:
# rebuild tree
webnotes.conn.set(self.doc,'old_parent', '')
self.update_nsm_model()
self.update_nsm()

View File

@@ -22,8 +22,20 @@ cur_frm.cscript.set_breadcrumbs = function(barea) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc);
}
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root
if(doc.name==='All Sales Persons') {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root sales person and cannot be edited.");
} else {
cur_frm.set_intro(null);
}
}
cur_frm.cscript.onload = function(){
}

View File

@@ -23,9 +23,20 @@ cur_frm.cscript.set_breadcrumbs = function(barea) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc);
}
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root territory
if(doc.name==='All Territories') {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root territory and cannot be edited.");
} else {
cur_frm.set_intro(null);
}
}
cur_frm.cscript.onload = function(){
}