Merge pull request #4500 from rmehta/fixes-to-tree
[fix] rename tree item fixes #2524
This commit is contained in:
commit
2da81732eb
@ -146,7 +146,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
label: __("Rename"),
|
label: __("Rename"),
|
||||||
click: function(node) {
|
click: function(node) {
|
||||||
frappe.model.rename_doc(me.ctype, node.label, function(new_name) {
|
frappe.model.rename_doc(me.ctype, node.label, function(new_name) {
|
||||||
node.reload();
|
node.reload_parent();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
btnClass: "hidden-xs"
|
btnClass: "hidden-xs"
|
||||||
@ -278,7 +278,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
if(node.expanded) {
|
if(node.expanded) {
|
||||||
node.toggle_node();
|
node.toggle_node();
|
||||||
}
|
}
|
||||||
node.reload();
|
node.load();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -324,7 +324,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
if(node.expanded) {
|
if(node.expanded) {
|
||||||
node.toggle_node();
|
node.toggle_node();
|
||||||
}
|
}
|
||||||
node.reload();
|
node.load();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,29 +18,31 @@ def get_companies():
|
|||||||
def get_children():
|
def get_children():
|
||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
ctype, company = args['ctype'], args['comp']
|
ctype, company = args['ctype'], args['comp']
|
||||||
|
fieldname = frappe.db.escape(ctype.lower().replace(' ','_'))
|
||||||
|
doctype = frappe.db.escape(ctype)
|
||||||
|
|
||||||
# root
|
# root
|
||||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
if args['parent'] in ("Accounts", "Cost Centers"):
|
||||||
select_cond = ", root_type, report_type, account_currency" if ctype=="Account" else ""
|
fields = ", root_type, report_type, account_currency" if ctype=="Account" else ""
|
||||||
acc = frappe.db.sql(""" select
|
acc = frappe.db.sql(""" select
|
||||||
name as value, is_group as expandable %s
|
name as value, is_group as expandable {fields}
|
||||||
from `tab%s`
|
from `tab{doctype}`
|
||||||
where ifnull(`parent_%s`,'') = ''
|
where ifnull(`parent_{fieldname}`,'') = ''
|
||||||
and `company` = %s and docstatus<2
|
and `company` = %s and docstatus<2
|
||||||
order by name""" % (select_cond, frappe.db.escape(ctype), frappe.db.escape(ctype.lower().replace(' ','_')), '%s'),
|
order by name""".format(fields=fields, fieldname = fieldname, doctype=doctype),
|
||||||
company, as_dict=1)
|
company, as_dict=1)
|
||||||
|
|
||||||
if args["parent"]=="Accounts":
|
if args["parent"]=="Accounts":
|
||||||
sort_root_accounts(acc)
|
sort_root_accounts(acc)
|
||||||
else:
|
else:
|
||||||
# other
|
# other
|
||||||
select_cond = ", account_currency" if ctype=="Account" else ""
|
fields = ", account_currency" if ctype=="Account" else ""
|
||||||
acc = frappe.db.sql("""select
|
acc = frappe.db.sql("""select
|
||||||
name as value, is_group as expandable %s
|
name as value, is_group as expandable, parent_{fieldname} as parent {fields}
|
||||||
from `tab%s`
|
from `tab{doctype}`
|
||||||
where ifnull(`parent_%s`,'') = %s
|
where ifnull(`parent_{fieldname}`,'') = %s
|
||||||
and docstatus<2
|
and docstatus<2
|
||||||
order by name""" % (select_cond, frappe.db.escape(ctype), frappe.db.escape(ctype.lower().replace(' ','_')), '%s'),
|
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
|
||||||
args['parent'], as_dict=1)
|
args['parent'], as_dict=1)
|
||||||
|
|
||||||
if ctype == 'Account':
|
if ctype == 'Account':
|
||||||
|
@ -155,7 +155,7 @@ erpnext.SalesChart = Class.extend({
|
|||||||
if(node.expanded) {
|
if(node.expanded) {
|
||||||
node.toggle_node();
|
node.toggle_node();
|
||||||
}
|
}
|
||||||
node.reload();
|
node.reload_parent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user