[fix] provision to handle custom mandatory params while creating node
This commit is contained in:
parent
ffa5ffe607
commit
2f02101d7d
@ -206,9 +206,12 @@ def get_count_on(account, fieldname, date):
|
||||
|
||||
@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 @@ def add_ac(args=None):
|
||||
|
||||
@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)
|
||||
|
@ -269,26 +269,13 @@ def get_children():
|
||||
|
||||
@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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user