How to get data from Child table to Doctype

Hi @FredericVerville,

I think, in js, it’s hard to implement for a child to parent fieldset.

Please apply the server script.

Script:

for d in doc.get('items'):
    batch_name = frappe.db.get_value("Batch", {'name': d.batch_no, 'item': d.item_code}, 'name')
    if batch_name:
        bn = frappe.get_doc("Batch", batch_name)
        bn.crop_type = d.crop_type
        bn.save()

Thank You!

1 Like