Item wise delivery date in Sales invoice table from delivery date of sales order item table

I want to import delivery date from sales order items table to sales invoice order table.
I have created delivery date field in table of sales invoice.
that means when I am making sales invoice of any sales order by clicking on “make ----> invoice”
or "Sales Invoice -----> new----->get items from -----> sales order "
then it should fetch the delivery date of that particular items into the sales invoice table of items.

delivery date in sales order

want the date here in sales invoice

I have tried following script but its fetching some random dates in table without making sales order, as onload is used

frappe.ui.form.on("Sales Invoice", "onload", function(frm, cdt, cdn) {{
    method: "frappe.client.get_list",
    args: {
        doctype: "Sales Order",
            filters: {
              "name": frm.doc.sales_order,
        fields: ["delivery_date"]
    callback: function(r) {
        var items = [];
        for (var i = 0; i < r.message.length; i++) {
            var d = frm.add_child("items");
            for (var key in r.message[i]) {
                if (r.message[i].hasOwnProperty(key)) {
                    frappe.model.set_value(d.doctype,, key, r.message[i][key]);

            if (!d.qty) d.qty = 1;