[fix] provision to handle custom mandatory params while creating node

This commit is contained in:
Saurabh 2017-01-11 12:41:01 +05:30
parent ffa5ffe607
commit 2f02101d7d
2 changed files with 13 additions and 20 deletions

View File

@ -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)

View File

@ -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():