[fix] provision to handle custom mandatory params while creating node
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 8e59d8f..b7fef75 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -206,9 +206,12 @@
@frappe.whitelist()
def add_ac(args=None):
+ from frappe.desk.treeview import make_tree_args
+
if not args:
args = frappe.local.form_dict
- args.pop("cmd")
+
+ args = make_tree_args(**args)
ac = frappe.new_doc("Account")
@@ -233,9 +236,12 @@
@frappe.whitelist()
def add_cc(args=None):
+ from frappe.desk.treeview import make_tree_args
+
if not args:
args = frappe.local.form_dict
- args.pop("cmd")
+
+ args = make_tree_args(**args)
cc = frappe.new_doc("Cost Center")
cc.update(args)
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index e01cc0b..5fa300f 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -269,26 +269,13 @@
@frappe.whitelist()
def add_node():
- doctype = frappe.form_dict.get('doctype')
- company = frappe.form_dict.get('company')
- parent_field = 'parent_' + doctype.lower().replace(' ', '_')
- name_field = doctype.lower().replace(' ', '_') + '_name'
+ from frappe.desk.treeview import make_tree_args
+ args = make_tree_args(**frappe.form_dict)
- doc = frappe.new_doc(doctype)
+ if cint(args.is_root):
+ args.parent_warehouse = None
- parent = frappe.form_dict['parent']
-
- if cint(frappe.form_dict['is_root']):
- parent = None
-
- doc.update({
- name_field: frappe.form_dict['warehouse_name'],
- parent_field: parent,
- "is_group": frappe.form_dict['is_group'],
- "company": company
- })
-
- doc.save()
+ frappe.get_doc(args).insert()
@frappe.whitelist()
def convert_to_group_or_ledger():