I want to add child tables dynamically depending on records in another doctype.
There are several method to add child in parent doc:
`
import frappe
parent = frappe.get_doc('Sales Order', 'SO-00002')
child = frappe.new_doc("Sales Order Item")
child.update({
'company': 'company_name',
'item_code': 'item_code',
'item_name': 'item_name',
'field': 'field_value'
'parent': parent.name,
'parenttype': 'Sales Order',
'parentfield': 'items'
})
parent.items.append(child)
import frappe
parent = frappe.get_doc('Sales Order', 'SO-00002')
child = frappe._dict({
'company': 'company_name',
'item_code': 'item_code',
'item_name': 'item_name',
'field': 'field_value'
})
parent.items.append(child)
`