From 16e2c18c646e8e5dcbc6f9ad31578d7d0d5c300e Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Mon, 10 Nov 2014 11:12:17 +0530 Subject: [PATCH] Delete events linked with employee on deletion of Employee --- erpnext/hr/doctype/employee/employee.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 16ae758b1b..6c27b23cd9 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -10,6 +10,7 @@ from frappe import throw, _, msgprint import frappe.permissions from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc +from erpnext.utilities.transaction_base import delete_events class EmployeeUserDisabledError(frappe.ValidationError): pass @@ -179,6 +180,9 @@ class Employee(Document): frappe.db.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee' and ref_name=%s""", self.name) + def on_trash(self): + delete_events(self.doctype, self.name) + @frappe.whitelist() def get_retirement_date(date_of_birth=None): import datetime