Custom app set values in child table

Hi, I am creating a custom app and I have created a new Doctype called ‘Solicitud de Capital’

I am trying to do is create a Journal Entry when the user create a new ‘Solicitud de Capital’

The problem comes when I am trying to set the values from child table inside the Jornal Entry.

In my solicitud_de_capital.py

class SolicituddeCapital(Document):
	def on_submit(self):
		asiento = frappe.new_doc("Journal Entry")
		asiento.prestamo = self.name
		asiento.save()

The DocFields can be set asiento.prestamo = self.name like this,

But I need to access the Child table values

How could I achive this.?
Thanks in advance.

let’s say your table name is ‘asientos_contables’, then you can do

for ac in self.asientos_contables:
    frappe.msgprint(_("Tercero: {0}").format(ac.tercero))

hi @mel_erp thank you for your response.

I think I explain myself bad for my bad english.

the child table values I need to set up are this:

But I need to populate that table from my New Doctype, And the scope of self. I think wouldn’t work.

yes, by using the code below you will access your own child table, from there you can do something like this:

for ac in self.asientos_contables:
    asiento.append("accounts", {
        "account": "some Account",
        "balance": 0,
        "cost_center": ac.some_cost_center,
        "party_type": "Customer",
        "party": "Some Customer",
        "party_balance": 0,
        "account_currency": "USD",
        "debit_in_account_currency" : 0,
        "debit": 0,
        "credit_in_account_currency" : "120.00",
        "credit" : "120.00",
        "project" : "project name",
        "is_advance" : "Yes"
    })

This will add a new ‘account’ in the table of account in the journal entry

3 Likes

thank you so much @mel_erp let me try it.

That’s what I was looking for…! Thanks @mel_erp.