How to set date in read only field after adding minutes to current time

heres my code:
.py

@frappe.whitelist()
def get_item_duration(item,starts_on):
it= frappe.get_doc(“Item”,item)
frappe.errprint(it.duration)
temp = datetime.strptime(starts_on, “%Y-%m-%d %H:%M:%S”)

end =temp + timedelta(minutes = it.duration)

return end

.js

starts_on: function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(!d.item){
console.log(“no item”);
msgprint(“enter item”);
}
else{
var duration = frappe.model.get_value(“Item”,d.item, duration);
console.log(duration);

  	frappe.call({
  	method: "appointment.appointment_manager.doctype.appointment.appointment.get_item_duration",
  	args: {
  		"item": d.item,
  		"starts_on": d.starts_on
  	},
  	callback: function(r) {
  		if(r.message) {
  			console.log("item duration");
  			//date = frappe.datetime.now_time();
  			//cur_frm.set_value("ends_on", frappe.datetime.now_time());

  			cur_frm.set_value(d.ends_on,r.message);

  			cur_frm.refresh_field(d.ends_on);
  			console.log(r.message);
  			}

  		}
  	});
  }

}

but the value does not get set, also tried with frm.set_value ,doc.set_value but no luck,
both these fields are in child table.
i am getting proper response and date in r.message.

What could be the reason

Thanks,

If ends_on is from a child table, you should be using frappe.model.set_value

thanks @tundebabzy for reply,

so,
frappe.model.set_value(“child table doctype”,d.name ,d.ends_on,date); ?
.
Is child table doctype ,the name of child table like “items” in sales invoice?
doesn’t seem to be working

As i was doing it infrappe.ui.form.on('child_table', { fields :function (frm){}

itself ,all i had to do was d.child_table_field = date_to_set and frappe.refresh_fields(child field)

Was that simple ,really complicated a simple implementation :sweat_smile: .

Thanks for the help