Issue when obtaining information from one Child table to another Child table

I have a custom Child table for the required Items in a custom Doctype. When I select an Item to manufacture, the required Items will be inserted in the Child table with some information about it. If I select a new Item to manufacture, the Child table must be updated to clear the fields and insert the new required Items in it.

My custom Child table obtains information from the Item in the Child table of the BOM Item.

This is the JS custom script:

bom_no: function (frm) {
    frappe.model.with_doc("BOM", frm.doc.bom_no, function() {
        var tabletransfer = frappe.model.get_doc("BOM", frm.doc.bom_no);

        if (cur_frm.doc.required_items) {

        $.each(tabletransfer.items, function (index, row) {
            d = frm.add_child("required_items");

            d.item_code     =  row.item_code;
            d.source_wh     =  frm.source_warehouse;
            d.item_name     =  row.item_name;
            d.unit_measure  =  row.uom;
	        d.required_qty  =  frm.doc.qty;


My problem is the following:

I want to get the quantity required for manufacturing from the qty field in the current Doctype, but the code does not work for that.
Also, the only fields that are filled in are item_code and source_wh, the rest do not receive the information.