mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 14:09:19 +00:00
create sales browser documents through wrapper
This commit is contained in:
@@ -18,12 +18,16 @@ def get_children():
|
|||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def add_node():
|
def add_node():
|
||||||
from webnotes.model.doc import Document
|
# from webnotes.model.doc import Document
|
||||||
ctype = webnotes.form_dict.get('ctype')
|
ctype = webnotes.form_dict.get('ctype')
|
||||||
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
||||||
|
name_field = ctype.lower().replace(' ', '_') + '_name'
|
||||||
d = Document(ctype)
|
|
||||||
d.fields[ctype.lower().replace(' ', '_') + '_name'] = webnotes.form_dict['name_field']
|
doclist = [{
|
||||||
d.fields[parent_field] = webnotes.form_dict['parent']
|
"doctype": ctype,
|
||||||
d.is_group = webnotes.form_dict['is_group']
|
"__islocal": 1,
|
||||||
d.save()
|
name_field: webnotes.form_dict['name_field'],
|
||||||
|
parent_field: webnotes.form_dict['parent'],
|
||||||
|
"is_group": webnotes.form_dict['is_group']
|
||||||
|
}]
|
||||||
|
webnotes.model_wrapper(doclist).save()
|
||||||
Reference in New Issue
Block a user