From 95f558e7bcb9b933c8e87e0655149508df560f07 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Sat, 10 May 2014 22:16:39 +0530 Subject: [PATCH] fix update user properties patch --- erpnext/hr/doctype/employee/employee.py | 2 ++ erpnext/patches/4_0/update_user_properties.py | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 6846b87bfc..687c6ce054 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -155,6 +155,8 @@ class Employee(Document): throw(_("Please enter relieving date.")) def validate_for_enabled_user_id(self): + if not self.status == 'Active': + return enabled = frappe.db.sql("""select name from `tabUser` where name=%s and enabled=1""", self.user_id) if not enabled: diff --git a/erpnext/patches/4_0/update_user_properties.py b/erpnext/patches/4_0/update_user_properties.py index dfec48bb96..1c746d378c 100644 --- a/erpnext/patches/4_0/update_user_properties.py +++ b/erpnext/patches/4_0/update_user_properties.py @@ -8,6 +8,7 @@ import frappe.defaults def execute(): frappe.reload_doc("core", "doctype", "docperm") + frappe.reload_doc("hr", "doctype", "employee") update_user_properties() update_user_match() add_employee_restrictions_to_leave_approver() @@ -82,13 +83,11 @@ def add_employee_restrictions_to_leave_approver(): # add Employee restrictions (in on_update method) for employee in frappe.db.sql_list("""select name from `tabEmployee` - where exists(select leave_approver from `tabEmployee Leave Approver` + where (exists(select leave_approver from `tabEmployee Leave Approver` where `tabEmployee Leave Approver`.parent=`tabEmployee`.name) - or ifnull(`reports_to`, '')!=''"""): + or ifnull(`reports_to`, '')!='') and docstatus<2 and status='Active'"""): - emp = frappe.get_doc("Employee", employee) - emp.ignore_links = True - emp.save() + frappe.get_doc("Employee", employee).save() def update_permissions(): # clear match conditions other than owner