I’m trying to add a function from the Timesheet list view that would act just like the “Make Time Log Batch” menu item in v6. So not being very capable of writing anything, I stole the snippet. (yes there are still residual terms and functions that have to be removed)
// select only billable timesheets
for(var i in selected) {
var d = selected[i];
//if(!d.billable) {
// msgprint(__("Timesheet is not billable") + ": " + d.name + " - " + d.title);
// return;
//}
if(d.status=="Batched for Billing") {
msgprint(__("Timesheet has been Batched for Billing") + ": " + d.name + " - " + d.title);
return;
}
if(d.status=="Billed") {
msgprint(__("Timesheet has been Billed") + ": " + d.name + " - " + d.title);
return;
}
if(d.status!="Submitted") {
msgprint(__("Timesheet Status must be Submitted.") + ": " + d.name + " - " + d.title);
return;
}
}
// make invoice
frappe.model.with_doctype("Sales Invoice", function() {
var sinv = frappe.model.get_new_doc("Sales Invoice");
$.each(selected, function(i, d) {
var detail = frappe.model.get_new_doc("Sales Invoice Timesheet", sinv,
"timesheets");
$.extend(detail, {
"time_sheet": d.name,
"billing_hours": d.total_billing_hours,
"billing_amount": d.total_billing_amount
});
})
frappe.set_route("Form", "Sales Invoice", sinv.name);
})
}, "icon-file-alt");
}
The problem is that when it enters the timesheet, the name shows up as the Timesheet, but not as a link, just text, and the other fields don’t populate.
Is there anything that needs to be called from sales_invoice.js or sales_invoice_timesheet.js? or a method in either .py?
Any help would be greatly appreciated. Thanks