From 798c6b4fdb5b63d94ef41680e8a1b9017d5f1362 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 13 Feb 2013 19:57:58 +0530 Subject: [PATCH] fixes in test runner and add role for profile --- hr/doctype/employee/employee.py | 2 +- hr/doctype/leave_application/leave_application.py | 4 +++- hr/doctype/leave_application/test_leave_application.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py index e357ff4907..cef6fdc697 100644 --- a/hr/doctype/employee/employee.py +++ b/hr/doctype/employee/employee.py @@ -76,7 +76,7 @@ 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): - from core.doctype.profile.profile import add_role + from webnotes.profile import add_role add_role(self.doc.user_id, "HR User") profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id) diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index 204514789e..bc685dfd55 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -78,7 +78,9 @@ class DocType: if block_date > from_date and block_date < to_date: webnotes.msgprint(_("You cannot apply for a leave on the following date because it is blocked") + ": " + formatdate(d.block_date) + _(" Reason: ") + d.reason) - raise LeaveDayBlockedError + if self.doc.docstatus == 1: + # throw exception only when submitting + raise LeaveDayBlockedError def is_user_in_allow_list(self, block_list): return webnotes.session.user in webnotes.conn.sql_list("""select allow_user diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py index ead0d0cddd..8fe11d66cc 100644 --- a/hr/doctype/leave_application/test_leave_application.py +++ b/hr/doctype/leave_application/test_leave_application.py @@ -20,7 +20,7 @@ class TestLeaveApplication(unittest.TestCase): webnotes.session.user = "test1@erpnext.com" - from core.doctype.profile.profile import add_role + from webnotes.profile import add_role add_role("test1@erpnext.com", "HR User") self.assertTrue(application.insert())