diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py index 16d8bff3ba0..ff030780fc6 100644 --- a/hr/doctype/employee/employee.py +++ b/hr/doctype/employee/employee.py @@ -78,11 +78,8 @@ class DocType: # add employee role if missing if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole where parent=%s""", self.doc.user_id): - profile_wrapper.doclist.append({ - "doctype": "UserRole", - "parentfield": "user_roles", - "role": "Employee" - }) + from core.doctype.profile.profile import add_role + add_role(self.doc.user_id, "HR User") # copy details like Fullname, DOB and Image to Profile if self.doc.employee_name: diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py index 7195826bf9b..ead0d0cddd0 100644 --- a/hr/doctype/leave_application/test_leave_application.py +++ b/hr/doctype/leave_application/test_leave_application.py @@ -19,7 +19,10 @@ class TestLeaveApplication(unittest.TestCase): self.assertRaises(LeaveDayBlockedError, application.insert) webnotes.session.user = "test1@erpnext.com" - webnotes.get_obj("Profile", "test1@erpnext.com").add_role("HR User") + + from core.doctype.profile.profile import add_role + add_role("test1@erpnext.com", "HR User") + self.assertTrue(application.insert()) def test_global_block_list(self):