Severe bug adding a timesheet entry from a project in V12

In version 12 there is a bug in project timesheets.
To reproduce the problem simply add a timesheet to a project by clicking on the plus sign next to Timesheets in the project dashboard.
A new timesheet will be opened with one timesheet entry detail with the project field prepopulated.
Trying to save the timesheet after filling in the details fails with the error.
Missing Fields
Mandatory fields required in Timesheet

Time Sheets

The prefilled out timesheet detail cannot be deleted.
It yields an error in the console .
console.trace() TypeError: “this.doc is undefined”
refresh_field grid_row.js:588
setup_columns grid_row.js:260
render_row grid_row.js:206
refresh grid_row.js:153
refresh grid.js:236
remove grid_row.js:79
remove grid_row.js:83
TypeError: this.doc is undefined

The only way to create a timesheet is to reload the new timesheet page which eliminates the prepopulated timesheet detail.
The user can then add a timesheet detail and save it.

I have done more testing with a fresh install of v12 and the problem exists there.
Switching to devolop branch also has the problem.
If I use and try it I notice that it doesnt prefill the project and doesnt have the problem. Is there a way to disable this pre-populating of the project.

Did you create an issue on GitHub?

replicated in my v12.06 system,

it is caused due to missing parent info in the created child docs in project.js file

frappe.ui.form.on("Project", {
	setup(frm) {
		frm.make_methods = {
			'Timesheet': () => {
				let doctype = 'Timesheet';
				frappe.model.with_doctype(doctype, () => {
					let new_doc = frappe.model.get_new_doc(doctype);
					// add a new row and set the project
					let time_log = frappe.model.get_new_doc('Timesheet Detail');
					time_log.project =;
					new_doc.time_logs = [time_log];
					frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);

following 3 lines to be added below this line time_log.project =;

				time_log.parent =;
				time_log.parentfield = 'time_logs';
				time_log.parenttype = 'Timesheet';
1 Like

Can I confirm, have solved as the same paralel on my test system

please mark as resolved,

Pull-Request #19316 created :+1: