I want from_time,to_time,hours of all tasks from timesheet detail(is a child table).I want these values in sprint.js(custom doctype).How it is possible.please help me
sprint.js [ Add this frappe.call wherever you need the data]
frappe.call({
method: 'path to your python file along with name of the function [get_details]', // Calling the method written in sprint.py
callback: function(r) {
// r catches the data returned from python side
for (var i in r.message){
// Iterate through each data and use it however you wish
console.log(r.message[i][0]);
}
}
});
sprint.py [ add it at the end of sprint’s python file]
@frappe.whitelist()
def get_details():
tasks = frappe.db.get_all('Task') # fetches all the tasks
timesheet_detail = []
for d in tasks:
# Iterating through each task and getting valus from that tasks Timesheet_Detail
temp = frappe.db.sql("""select from_time, to_time, hours, task from `tabTimesheet Detail` where task = %(task)s""", {'task': d.name}, as_dict=1)
if temp:
# If the task had a timesheet detail associated with it, append it to the array
timesheet_detail.append(temp)
return timesheet_detail # returning to the js side
Maybe you can get some ideas from this I hope.
ok thanks for the reply
.How we can pass the start_date,end_date through frappe call .Then we have to update the query
frappe.call({
method: 'path to your python file along with name of the function [get_details]', // Calling the method written in sprint.py
args: {
start_date: //Whichever variable holds start date
end_date: //Whichever variable holds end date
},
callback: function(r) {
// r catches the data returned from python side
for (var i in r.message){
// Iterate through each data and use it however you wish
console.log(r.message[i][0]);
}
}
});
You’ll also need to add this two args as parameters in python method to catch them.