How i can make the program run when any sales order documents get open

frappe.ui.form.on('Sales Order', {
    when open: function(frm, cdt, cdn) {
        if (frm.doc.custom_test == "Production") {
            frm.doc.items.forEach(function(row) { 
                let item_series = frm.add_child('custom_item_serial'); // bottom child table field name
                item_series.item_series = row.item_name;
                frm.refresh_field('custom_item_serial');
            });
        }
    }
});

can any one make this code run when the document open

Hi,

refresh: function(frm)