diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0c6a978a9b..dfc926dc66 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -316,3 +316,4 @@ erpnext.patches.v7_0.repost_gle_for_pos_sales_return 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") diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 0379f906de..0c49353931 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -20,12 +20,17 @@ class OverProductionLoggedError(frappe.ValidationError): pass class Timesheet(Document): def validate(self): + self.set_employee_name() self.set_status() self.validate_dates() self.validate_time_logs() self.update_cost() self.calculate_total_amounts() + def set_employee_name(self): + if self.employee and not self.employee_name: + self.employee_name = frappe.db.get_value('Employee', self.employee, 'employee_name') + def calculate_total_amounts(self): self.total_hours = 0.0 self.total_billing_amount = 0.0