tree based changes

This commit is contained in:
Zlash65 2018-04-20 16:00:55 +05:30
parent 93d6b555d7
commit f665189ab3
2 changed files with 34 additions and 4 deletions

View File

@ -2,7 +2,27 @@
// For license information, please see license.txt
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro(doc.__islocal ? "" : __("There is nothing to edit."))
cur_frm.set_intro(doc.__islocal ? "" : __("There is nothing to edit."));
cur_frm.cscript.set_root_readonly(doc);
}
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root customer group
if(!doc.parent_supplier_group) {
cur_frm.set_read_only();
cur_frm.set_intro(__("This is a root supplier group and cannot be edited."));
} else {
cur_frm.set_intro(null);
}
}
//get query select Customer Group
cur_frm.fields_dict['parent_supplier_group'].get_query = function(doc,cdt,cdn) {
return {
filters: {
'is_group': 1
}
}
}
cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(doc, cdt, cdn) {

View File

@ -4,7 +4,17 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.utils.nestedset import NestedSet
class SupplierGroup(Document):
pass
class SupplierGroup(NestedSet):
nsm_parent_field = 'parent_supplier_group';
def update_nsm_model(self):
frappe.utils.nestedset.update_nsm(self)
def on_update(self):
self.update_nsm_model()
self.validate_one_root()
def on_trash(self):
self.update_nsm_model()