Calculate values in child table - Script help

Hi Guys , i have a problem to update the values in child table.

Timesheet function have child table called “time logs” . In this child table there is a field “hours” that I want to be calculated from custom fields that are also located in child table.

For eample : if I am filling out timesheet i put there some timesheet details rows to mark up hours on the projects.

I tried every script example but it’s not working even with some simples one.

// make a field read-only after saving
frappe.ui.form.on("Timesheet Detail", {
    refresh: function(frm) {
    //all of these fields are on Timesheet Detail level (in child table time_logs)
    var total_hours = frm.doc.mon + frm.doc.tue + ....
        frm.set_df_property("hours", total_hours);

is this correct approach ? or i need to somehow use the parent doctype ?

Thank you very much for advices, i am desperate.


set_df_property is use to set the field properties like hidden, readonly, mandatory

to make field readonly use frm.set_df_property("readonly", 1); or frm.toggle_enable method

to set value use cur_frm.set_value or frappe.model.set_value methods

Thanks, Makarand