Create new Record From Another Doctype when save

i have doctype called “Test” have Four Fields type link account_1 , account_2 and amount_1 and amount_2 amount is float type,
i want the data entered in four Fields when i press Save to copy this data to create journal entry new record and add this data in child table accounts in (account_1 to acccount )and account_1 to debit next row (account_2 to account) to (amount_2 to credit)

You may use document api for that. Document API

i got internal server error

But which one???

What do you want to achieve?

after save , i want new entry. it’s mean automatically navigate to new entry detailed view. in same doctype