diff --git a/erpnext/patches.txt b/erpnext/patches.txt index be0013e3ff..f06e385276 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -315,4 +315,5 @@ erpnext.patches.v7_0.update_missing_employee_in_timesheet erpnext.patches.v7_0.update_status_for_timesheet erpnext.patches.v7_0.set_party_name_in_payment_entry execute:frappe.db.sql("update `tabTimesheet` ts, `tabEmployee` emp set ts.employee_name = emp.employee_name where emp.name = ts.employee and ts.employee_name is null and ts.employee is not null") +execute:frappe.db.sql("delete from `tabTimesheet Detail` where NOT EXISTS (select name from `tabTimesheet` where name = `tabTimesheet Detail`.parent)") erpnext.patches.v7_0.update_mode_of_payment_type diff --git a/erpnext/setup/doctype/company/delete_company_transactions.py b/erpnext/setup/doctype/company/delete_company_transactions.py index 7e1681c38e..8f058e86ed 100644 --- a/erpnext/setup/doctype/company/delete_company_transactions.py +++ b/erpnext/setup/doctype/company/delete_company_transactions.py @@ -18,7 +18,6 @@ def delete_company_transactions(company_name): frappe.PermissionError) delete_bins(company_name) - delete_time_sheets(company_name) delete_lead_addresses(company_name) for doctype in frappe.db.sql_list("""select parent from @@ -70,14 +69,6 @@ def delete_bins(company_name): frappe.db.sql("""delete from tabBin where warehouse in (select name from tabWarehouse where company=%s)""", company_name) -def delete_time_sheets(company_name): - # Delete Time Logs as it is linked to Production Order / Project / Task, which are linked to company - frappe.db.sql(""" - delete from `tabTimesheet` - where - company=%(company)s - """, {"company": company_name}) - def delete_lead_addresses(company_name): """Delete addresses to which leads are linked""" for lead in frappe.get_all("Lead", filters={"company": company_name}):