fixed sales / accounts tree
This commit is contained in:
parent
05b28eb161
commit
e0e3f92019
@ -109,97 +109,75 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
args: {ctype: ctype, comp: company},
|
args: {ctype: ctype, comp: company},
|
||||||
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
|
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
|
||||||
click: function(link) {
|
click: function(link) {
|
||||||
if(me.cur_toolbar)
|
|
||||||
$(me.cur_toolbar).toggle(false);
|
|
||||||
|
|
||||||
if(!link.toolbar)
|
|
||||||
me.make_link_toolbar(link);
|
|
||||||
|
|
||||||
if(link.toolbar) {
|
|
||||||
me.cur_toolbar = link.toolbar;
|
|
||||||
$(me.cur_toolbar).toggle(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bold
|
// bold
|
||||||
$('.bold').removeClass('bold'); // deselect
|
$('.bold').removeClass('bold'); // deselect
|
||||||
$(link).parent().find('.balance-area:first').addClass('bold'); // select
|
$(link).parent().find('.balance-area:first').addClass('bold'); // select
|
||||||
|
|
||||||
},
|
},
|
||||||
onrender: function(treenode) {
|
toolbar: [
|
||||||
if (ctype == 'Account' && treenode.data) {
|
{ toggle_btn: true },
|
||||||
if(treenode.data.balance) {
|
{
|
||||||
treenode.parent.append('<span class="balance-area pull-right">'
|
label: __("Open"),
|
||||||
+ format_currency(treenode.data.balance, treenode.data.currency)
|
condition: function(node) { return !node.root },
|
||||||
+ '</span>');
|
click: function(node, btn) {
|
||||||
|
frappe.set_route("Form", me.ctype, node.label);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: function(node) { return !node.root && node.expandable; },
|
||||||
|
label: __("Add Child"),
|
||||||
|
click: function() {
|
||||||
|
if(me.ctype=='Account') {
|
||||||
|
me.new_account();
|
||||||
|
} else {
|
||||||
|
me.new_cost_center();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: function(node) {
|
||||||
|
return !node.root && me.ctype === 'Account'
|
||||||
|
&& frappe.boot.profile.can_read.indexOf("GL Entry") !== -1
|
||||||
|
},
|
||||||
|
label: __("View Ledger"),
|
||||||
|
click: function(node, btn) {
|
||||||
|
frappe.route_options = {
|
||||||
|
"account": node.label,
|
||||||
|
"from_date": sys_defaults.year_start_date,
|
||||||
|
"to_date": sys_defaults.year_end_date,
|
||||||
|
"company": me.company
|
||||||
|
};
|
||||||
|
frappe.set_route("query-report", "General Ledger");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: function(node) { return !node.root && me.can_write },
|
||||||
|
label: __("Rename"),
|
||||||
|
click: function(node) {
|
||||||
|
frappe.model.rename_doc(me.ctype, node.label, function(new_name) {
|
||||||
|
node.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
condition: function(node) { return !node.root && me.can_delete },
|
||||||
|
label: __("Delete"),
|
||||||
|
click: function(node) {
|
||||||
|
frappe.model.delete_doc(me.ctype, node.label, function() {
|
||||||
|
node.parent.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onrender: function(node) {
|
||||||
|
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
||||||
|
$('<span class="balance-area pull-right text-muted">'
|
||||||
|
+ format_currency(node.data.balance, node.data.currency)
|
||||||
|
+ '</span>').insertBefore(node.$ul);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.tree.rootnode.$a.click();
|
|
||||||
},
|
|
||||||
make_link_toolbar: function(link) {
|
|
||||||
var data = $(link).data('node-data');
|
|
||||||
if(!data) return;
|
|
||||||
|
|
||||||
link.toolbar = $('<span class="tree-node-toolbar highlight"></span>').insertAfter(link);
|
|
||||||
|
|
||||||
var node_links = [];
|
|
||||||
// edit
|
|
||||||
if (frappe.model.can_read(this.ctype) !== -1) {
|
|
||||||
node_links.push('<a onclick="erpnext.account_chart.open();">'+frappe._('Edit')+'</a>');
|
|
||||||
}
|
|
||||||
if (data.expandable && frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
|
||||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+frappe._('Add Child')+'</a>');
|
|
||||||
} else if (this.ctype === 'Account' && frappe.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
|
||||||
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+frappe._('View Ledger')+'</a>');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.can_write) {
|
|
||||||
node_links.push('<a onclick="erpnext.account_chart.rename()">'+frappe._('Rename')+'</a>');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.can_delete) {
|
|
||||||
node_links.push('<a onclick="erpnext.account_chart.delete()">'+frappe._('Delete')+'</a>');
|
|
||||||
};
|
|
||||||
|
|
||||||
link.toolbar.append(node_links.join(" | "));
|
|
||||||
},
|
|
||||||
open: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.set_route("Form", this.ctype, node.data("label"));
|
|
||||||
},
|
|
||||||
show_ledger: function() {
|
|
||||||
var me = this;
|
|
||||||
var node = me.selected_node();
|
|
||||||
frappe.route_options = {
|
|
||||||
"account": node.data('label'),
|
|
||||||
"from_date": sys_defaults.year_start_date,
|
|
||||||
"to_date": sys_defaults.year_end_date,
|
|
||||||
"company": me.company
|
|
||||||
};
|
|
||||||
frappe.set_route("query-report", "General Ledger");
|
|
||||||
},
|
|
||||||
rename: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.model.rename_doc(this.ctype, node.data('label'), function(new_name) {
|
|
||||||
node.parents("ul:first").parent().find(".tree-link:first").trigger("reload");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
delete: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.model.delete_doc(this.ctype, node.data('label'), function() {
|
|
||||||
node.parent().remove();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
new_node: function() {
|
|
||||||
if(this.ctype=='Account') {
|
|
||||||
this.new_account();
|
|
||||||
} else {
|
|
||||||
this.new_cost_center();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selected_node: function() {
|
|
||||||
return this.tree.$w.find('.tree-link.selected');
|
|
||||||
},
|
},
|
||||||
new_account: function() {
|
new_account: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -250,12 +228,11 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
// create
|
// create
|
||||||
$(fd.create_new.input).click(function() {
|
$(fd.create_new.input).click(function() {
|
||||||
var btn = this;
|
var btn = this;
|
||||||
$(btn).set_working();
|
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
v.parent_account = node.data('label');
|
v.parent_account = node.label;
|
||||||
v.master_type = '';
|
v.master_type = '';
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
@ -263,9 +240,8 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_ac',
|
method: 'erpnext.accounts.utils.add_ac',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
$(btn).done_working();
|
|
||||||
d.hide();
|
d.hide();
|
||||||
node.trigger('reload');
|
node.reload;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -296,23 +272,20 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
|
|
||||||
// create
|
// create
|
||||||
$(d.fields_dict.create_new.input).click(function() {
|
$(d.fields_dict.create_new.input).click(function() {
|
||||||
var btn = this;
|
|
||||||
$(btn).set_working();
|
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
|
|
||||||
v.parent_cost_center = node.data('label');
|
v.parent_cost_center = node.label;
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_cc',
|
method: 'erpnext.accounts.utils.add_cc',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
$(btn).done_working();
|
|
||||||
d.hide();
|
d.hide();
|
||||||
node.trigger('reload');
|
node.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -56,57 +56,56 @@ erpnext.SalesChart = Class.extend({
|
|||||||
$(parent).empty();
|
$(parent).empty();
|
||||||
var me = this;
|
var me = this;
|
||||||
me.ctype = ctype;
|
me.ctype = ctype;
|
||||||
|
me.can_read = frappe.model.can_read(this.ctype);
|
||||||
|
me.can_create = frappe.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
|
||||||
|
frappe.boot.profile.in_create.indexOf(this.ctype) !== -1;
|
||||||
|
me.can_write = frappe.model.can_write(this.ctype);
|
||||||
|
me.can_delete = frappe.model.can_delete(this.ctype);
|
||||||
|
|
||||||
this.tree = new frappe.ui.Tree({
|
this.tree = new frappe.ui.Tree({
|
||||||
parent: $(parent),
|
parent: $(parent),
|
||||||
label: root,
|
label: root,
|
||||||
args: {ctype: ctype},
|
args: {ctype: ctype},
|
||||||
method: 'erpnext.selling.page.sales_browser.sales_browser.get_children',
|
method: 'erpnext.selling.page.sales_browser.sales_browser.get_children',
|
||||||
click: function(link) {
|
toolbar: [
|
||||||
if(me.cur_toolbar)
|
{toggle_btn: true},
|
||||||
$(me.cur_toolbar).toggle(false);
|
{
|
||||||
|
label:__("Edit"),
|
||||||
if(!link.toolbar)
|
condition: function(node) {
|
||||||
me.make_link_toolbar(link);
|
return !node.root && me.can_read;
|
||||||
|
},
|
||||||
if(link.toolbar) {
|
click: function(node) {
|
||||||
me.cur_toolbar = link.toolbar;
|
frappe.set_route("Form", me.ctype, node.label);
|
||||||
$(me.cur_toolbar).toggle(true);
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:__("Add Child"),
|
||||||
|
condition: function(node) { return me.can_create && node.expandable; },
|
||||||
|
click: function(node) {
|
||||||
|
me.new_node();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:__("Rename"),
|
||||||
|
condition: function(node) { return !node.root && me.can_write; },
|
||||||
|
click: function(node) {
|
||||||
|
frappe.model.rename_doc(me.ctype, node.label, function(new_name) {
|
||||||
|
node.$a.html(new_name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:__("Delete"),
|
||||||
|
condition: function(node) { return !node.root && me.can_delete; },
|
||||||
|
click: function(node) {
|
||||||
|
frappe.model.delete_doc(me.ctype, node.label, function() {
|
||||||
|
node.parent.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
]
|
||||||
});
|
});
|
||||||
this.tree.rootnode.$a
|
|
||||||
.data('node-data', {value: root, expandable:1})
|
|
||||||
.click();
|
|
||||||
},
|
|
||||||
make_link_toolbar: function(link) {
|
|
||||||
var data = $(link).data('node-data');
|
|
||||||
if(!data) return;
|
|
||||||
|
|
||||||
link.toolbar = $('<span class="tree-node-toolbar"></span>').insertAfter(link);
|
|
||||||
|
|
||||||
// edit
|
|
||||||
var node_links = [];
|
|
||||||
|
|
||||||
if (frappe.model.can_read(this.ctype)) {
|
|
||||||
node_links.push('<a onclick="erpnext.sales_chart.open();">'+frappe._('Edit')+'</a>');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(data.expandable) {
|
|
||||||
if (frappe.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
|
|
||||||
frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
|
||||||
node_links.push('<a onclick="erpnext.sales_chart.new_node();">' + frappe._('Add Child') + '</a>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frappe.model.can_write(this.ctype)) {
|
|
||||||
node_links.push('<a onclick="erpnext.sales_chart.rename()">' + frappe._('Rename') + '</a>');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (frappe.model.can_delete(this.ctype)) {
|
|
||||||
node_links.push('<a onclick="erpnext.sales_chart.delete()">' + frappe._('Delete') + '</a>');
|
|
||||||
};
|
|
||||||
|
|
||||||
link.toolbar.append(node_links.join(" | "));
|
|
||||||
},
|
},
|
||||||
new_node: function() {
|
new_node: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -134,44 +133,23 @@ erpnext.SalesChart = Class.extend({
|
|||||||
// create
|
// create
|
||||||
$(d.fields_dict.create_new.input).click(function() {
|
$(d.fields_dict.create_new.input).click(function() {
|
||||||
var btn = this;
|
var btn = this;
|
||||||
$(btn).set_working();
|
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
|
|
||||||
v.parent = node.data('label');
|
v.parent = node.label;
|
||||||
v.ctype = me.ctype;
|
v.ctype = me.ctype;
|
||||||
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: 'erpnext.selling.page.sales_browser.sales_browser.add_node',
|
method: 'erpnext.selling.page.sales_browser.sales_browser.add_node',
|
||||||
args: v,
|
args: v,
|
||||||
callback: function() {
|
callback: function() {
|
||||||
$(btn).done_working();
|
|
||||||
d.hide();
|
d.hide();
|
||||||
node.trigger('reload');
|
node.reload();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
selected_node: function() {
|
|
||||||
return this.tree.$w.find('.tree-link.selected');
|
|
||||||
},
|
|
||||||
open: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.set_route("Form", this.ctype, node.data("label"));
|
|
||||||
},
|
|
||||||
rename: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.model.rename_doc(this.ctype, node.data('label'), function(new_name) {
|
|
||||||
node.data('label', new_name).find(".tree-label").html(new_name);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
delete: function() {
|
|
||||||
var node = this.selected_node();
|
|
||||||
frappe.model.delete_doc(this.ctype, node.data('label'), function() {
|
|
||||||
node.parent().remove();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
@ -1,5 +1,3 @@
|
|||||||
<h2><i class="icon-home"></i> Sample Home Page</h2>
|
|
||||||
<br>
|
|
||||||
<p>This is a sample home page for your company <b>%(name)s's</b> website. This was
|
<p>This is a sample home page for your company <b>%(name)s's</b> website. This was
|
||||||
created from the Website Module inside ERPNext. ERPNext provides you with simple
|
created from the Website Module inside ERPNext. ERPNext provides you with simple
|
||||||
tools to build and update your website. You can add sections like your Product Catalog,
|
tools to build and update your website. You can add sections like your Product Catalog,
|
||||||
|
@ -371,11 +371,11 @@ frappe.wiz.WizardSlide = Class.extend({
|
|||||||
this.$wrapper = $(repl('<div class="panel panel-default">\
|
this.$wrapper = $(repl('<div class="panel panel-default">\
|
||||||
<div class="panel-heading">\
|
<div class="panel-heading">\
|
||||||
<div class="panel-title row">\
|
<div class="panel-title row">\
|
||||||
<div class="col-sm-8">\
|
<div class="col-sm-8"><h3 style="margin: 0px;">\
|
||||||
<i class="%(icon)s text-muted"></i> %(title)s</div>\
|
<i class="%(icon)s text-muted"></i> %(title)s</h3></div>\
|
||||||
<div class="col-sm-4 text-right"><a class="prev-btn hide">Previous</a> \
|
<div class="col-sm-4 text-right"><a class="prev-btn hide btn btn-default">Previous</a> \
|
||||||
<a class="next-btn hide">Next</a> \
|
<a class="next-btn hide btn btn-primary">Next</a> \
|
||||||
<a class="complete-btn hide"><b>Complete Setup</b></a>\
|
<a class="complete-btn hide btn btn-primary"><b>Complete Setup</b></a>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user