Try ERPNext Buy Support Partners Foundation

Create a new doc from script and bet back to the origin with the new doc name

Dear All,

i add 2 custom fields in Purchase Receipt Item childTable as below
cat_doc link to docType TestCatTrans docType
create_cat_doc button with below custom script

frappe.ui.form.on(‘Purchase Receipt Item’, {
create_cat_doc: function(frm, cdt, cdn){
var d = locals[cdt][cdn]
var local_docname = frappe.model.make_new_doc_and_get_name(‘TestCatTrans’)
d.cat_doc = local_docname
frappe.set_route(‘Form’, ‘TestCatTrans’, local_docname)
}
})

the problems are
1- the new TestCatTrans doc is not returning back to the Purchase Receipt after saving
2- The TestCatTrans has series naming , so its name is changed after save , and i want to set the cat_doc with its new name after back to Purhase Receipt
3- Is it possible theat set_route open the new doc in quick entry mode?

Thanks for your help