[enhance] treeview to BOM, sales person, Cost Center and Chart of acounts
diff --git a/erpnext/accounts/doctype/account/account_treeview.js b/erpnext/accounts/doctype/account/account_treeview.js
new file mode 100644
index 0000000..673ef9f
--- /dev/null
+++ b/erpnext/accounts/doctype/account/account_treeview.js
@@ -0,0 +1,37 @@
+frappe.treeview_settings["Account"] = {
+ breadcrumbs: "Accounts",
+ title: __("Chart Of Accounts"),
+ get_tree_root: false,
+ filters: [{
+ fieldname: "comp",
+ fieldtype:"Select",
+ options: $.map(locals[':Company'], function(c) { return c.name; }).sort(),
+ label: __("Company")
+ }],
+ root_label: "Accounts",
+ get_tree_nodes: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
+ add_tree_node: 'erpnext.accounts.utils.add_ac',
+ menu_items:[
+ {
+ label: __('New Company'),
+ action: function() { newdoc('Company'); },
+ condition: 'frappe.boot.user.can_create.indexOf("Company") === -1'
+ }
+ ],
+ fields: [
+ {fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
+ description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers")},
+ {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
+ description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
+ {fieldtype:'Select', fieldname:'root_type', label:__('Root Type'),
+ options: ['Asset', 'Liability', 'Equity', 'Income', 'Expense'].join('\n'),
+ },
+ {fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
+ options: ['', 'Bank', 'Cash', 'Warehouse', 'Tax', 'Chargeable'].join('\n'),
+ description: __("Optional. This setting will be used to filter in various transactions.") },
+ {fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate')},
+ {fieldtype:'Link', fieldname:'warehouse', label:__('Warehouse'), options:"Warehouse"},
+ {fieldtype:'Link', fieldname:'account_currency', label:__('Currency'), options:"Currency",
+ description: __("Optional. Sets company's default currency, if not specified.")}
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/cost_center/cost_center_treeview.js b/erpnext/accounts/doctype/cost_center/cost_center_treeview.js
new file mode 100644
index 0000000..c3a222d
--- /dev/null
+++ b/erpnext/accounts/doctype/cost_center/cost_center_treeview.js
@@ -0,0 +1,25 @@
+frappe.treeview_settings["Cost Center"] = {
+ breadcrumbs: "Accounts",
+ get_tree_root: false,
+ filters: [{
+ fieldname: "comp",
+ fieldtype:"Select",
+ options: $.map(locals[':Company'], function(c) { return c.name; }).sort(),
+ label: __("Company"),
+ }],
+ root_label: "Cost Centers",
+ get_tree_nodes: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
+ add_tree_node: 'erpnext.accounts.utils.add_cc',
+ menu_items:[
+ {
+ label: __('New Company'),
+ action: function() { newdoc('Company'); },
+ condition: 'frappe.boot.user.can_create.indexOf("Company") === -1'
+ }
+ ],
+ fields:[
+ {fieldtype:'Data', fieldname:'cost_center_name', label:__('New Cost Center Name'), reqd:true},
+ {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
+ description:__('Further cost centers can be made under Groups but entries can be made against non-Groups')}
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 27f1394..06c15d7 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -135,6 +135,10 @@
args.pop("ignore_permissions")
ac.update(args)
+
+ if not ac.parent_account:
+ ac.parent_account = args.get("parent")
+
ac.old_parent = ""
ac.freeze_account = "No"
if cint(ac.get("is_root")):
@@ -153,6 +157,10 @@
cc = frappe.new_doc("Cost Center")
cc.update(args)
+
+ if not cc.parent_cost_center:
+ cc.parent_cost_center = args.get("parent")
+
cc.old_parent = ""
cc.insert()
return cc.name
diff --git a/erpnext/manufacturing/doctype/bom/bom_treeview.js b/erpnext/manufacturing/doctype/bom/bom_treeview.js
index 359acdf..68ed4e2 100644
--- a/erpnext/manufacturing/doctype/bom/bom_treeview.js
+++ b/erpnext/manufacturing/doctype/bom/bom_treeview.js
@@ -8,9 +8,10 @@
label: __("BOM")
}
],
+ title: "BOM",
breadcrumb: "Manufacturing",
disable_add_node: true,
- label: "bom", // should be fieldname from filters
+ root_label: "bom", //fieldname from filters
get_label: function(node) {
if(node.data.qty) {
return node.data.qty + " x " + node.data.item_code;
diff --git a/erpnext/setup/doctype/sales_person/sales_person_treeview.js b/erpnext/setup/doctype/sales_person/sales_person_treeview.js
new file mode 100644
index 0000000..fd2127d
--- /dev/null
+++ b/erpnext/setup/doctype/sales_person/sales_person_treeview.js
@@ -0,0 +1,11 @@
+frappe.treeview_settings["Sales Person"] = {
+ fields: [
+ {fieldtype:'Data', fieldname: 'name_field',
+ label:__('New Sales Person Name'), reqd:true},
+ {fieldtype:'Link', fieldname:'employee',
+ label:__('Employee'), options:'Employee',
+ description: __("Please enter Employee Id of this sales person")},
+ {fieldtype:'Select', fieldname:'is_group', label:__('Group Node'), options:'No\nYes',
+ description: __("Further nodes can be only created under 'Group' type nodes")}
+ ],
+}
\ No newline at end of file