mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-28 02:58:30 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
// read-only for root customer group
|
||||
if(doc.name==='All Customer Groups') {
|
||||
if(!doc.parent_customer_group) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root customer group and cannot be edited.");
|
||||
} else {
|
||||
|
||||
@@ -31,20 +31,29 @@ class DocType(DocTypeNestedSet):
|
||||
self.nsm_parent_field = 'parent_customer_group';
|
||||
|
||||
def validate(self):
|
||||
if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
|
||||
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")
|
||||
To untrash please go to Setup -> Recycle Bin.""" %
|
||||
(self.doc.customer_group_name), raise_exception = 1)
|
||||
|
||||
super(DocType, self).validate()
|
||||
|
||||
|
||||
def on_trash(self):
|
||||
cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name)
|
||||
cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s",
|
||||
self.doc.name)
|
||||
cust = [d[0] for d in cust]
|
||||
if cust:
|
||||
msgprint("""Customer Group: %s can not be trashed/deleted because it is used in customer: %s.
|
||||
To trash/delete this, remove/change customer group in customer master""" % (self.doc.name, cust or ''), raise_exception=1)
|
||||
msgprint("""Customer Group: %s can not be trashed/deleted \
|
||||
because it is used in customer: %s.
|
||||
To trash/delete this, remove/change customer group in customer master""" %
|
||||
(self.doc.name, cust or ''), raise_exception=1)
|
||||
|
||||
if sql("select name from `tabCustomer Group` where parent_customer_group = %s and docstatus != 2", self.doc.name):
|
||||
msgprint("Child customer group exists for this customer group. You can not trash/cancel/delete this customer group.", raise_exception=1)
|
||||
if sql("select name from `tabCustomer Group` where parent_customer_group = %s \
|
||||
and docstatus != 2", self.doc.name):
|
||||
msgprint("Child customer group exists for this customer group. \
|
||||
You can not trash/cancel/delete this customer group.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
super(DocType, self).on_trash()
|
||||
super(DocType, self).on_trash()
|
||||
@@ -14,6 +14,21 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
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 item group
|
||||
if(!doc.parent_item_group) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root item group and cannot be edited.");
|
||||
} else {
|
||||
cur_frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
|
||||
//get query select item group
|
||||
cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
|
||||
|
||||
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
// read-only for root
|
||||
if(doc.name==='All Sales Persons') {
|
||||
if(!doc.parent_sales_person) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root sales person and cannot be edited.");
|
||||
} else {
|
||||
|
||||
@@ -33,3 +33,6 @@ class DocType(DocTypeNestedSet):
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
webnotes.msgprint("Either target qty or target amount is mandatory.")
|
||||
raise Exception
|
||||
|
||||
super(DocType, self).validate()
|
||||
|
||||
@@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
// read-only for root territory
|
||||
if(doc.name==='All Territories') {
|
||||
if(!doc.parent_territory) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root territory and cannot be edited.");
|
||||
} else {
|
||||
@@ -28,12 +28,6 @@ cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//get query select territory
|
||||
cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
|
||||
@@ -33,3 +33,6 @@ 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
|
||||
|
||||
super(DocType, self).validate()
|
||||
|
||||
Reference in New Issue
Block a user