Create Journal Entry from New Document in custom app

Hi, (I’m am new programming) I’m creating a custom app from scratch (learning),
and I create a DocType Called Prestamos and I need to create a Journal Entry when the Prestamos document is created with a linked field on it (Prestamos docname),
Is there a way to make it happen?
And is there a code where I can check how it works? or any example of this.

In the method on_submit on this doctype, I want to run the methods from

But I need to pass the ammount or pass the details to the new Journal Entry, And I dunno how to aproach to it.

Hey ! Welcome to the community.

Yes. definitely.

Check this code.

You need to write similar lines for your function which you can invoke in any hook you want. (Read about Document Hooks on this link :

This can be done but after you save your Prestamos doc. You need to make a Custom Field via Customize Form. Name it appropriately. Here’s a link for that : Creating Custom Link Field

Since you want you link your Prestamos document to the Journal Entry, your doc must be saved before you are creating this new Journal Entry. Linking is simple.

Assuming, your field Field is labelled : prestamos this line should be:

journal_entry.prestamos =

I am assuming you would make a class function hence I used self.

EDIT : You should run this journal entry function on the after_insert hook.

1 Like

thanks man, that was I was looking for, I really appreciate it. I’m in my job right now, but when I get home, I’ll take a look at it, and let you guys know. :sunglasses:

Sorry if I am multithreading (I don’t know if that word even exist) here, but I need to know, after I finish my custom app development, Can I pack it and install on a production site? if so, can you point me the documentation to achive that.

thank you in advance.

Yes. Just like this:

bench get-app

It could be a github link or bitbucket. You don’t need to pack anything. Frappe has already done it for you. Make sure your changes are updated at all times.

This case is to install it. But I was talking about to upload my custom app to my github. And be able to do this

Any time I need.

oh, I guess I skipped the github connection part. I did already, Now I understand what you were talking about, now it make sense, sorry about it, Im kind of newbie.
Let me continue making test and learning.

Thank u so much man.

I am advancing, but I’m stuck, I can’t access to childtable fields to set them up.
In this case i need to assign the child table Journal Entry Account(accounts) values in the Journal Entry Doctype, because, those fields are mandatory and I need to fill them up.

asiento = frappe.new_doc("Journal Entry")
asiento.prestamo =
asiento.accounts[0].account = "1110 - Efectivo - JD"

this was my approach, but didn’t work.
I was reading this, but it is over JS, I don’t know the scoop of it and if that’s what I need.