[minor] move warehouse user to restrictions

This commit is contained in:
Anand Doshi
2013-12-09 12:04:49 +05:30
parent 57518fc5f1
commit 83638b5f05
14 changed files with 81 additions and 95 deletions

View File

@@ -151,7 +151,7 @@ class DocType(DocListController):
employee = webnotes.bean("Employee", self.doc.employee)
leave_approvers = [l.leave_approver for l in
employee.doclist.get({"parentfield": "employee_leave_approvers"})]
if len(leave_approvers) and self.doc.leave_approver not in leave_approvers:
msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] '
+ _("Leave Approver can be one of") + ": "

View File

@@ -10,6 +10,9 @@ class TestLeaveApplication(unittest.TestCase):
def tearDown(self):
webnotes.set_user("Administrator")
# so that this test doesn't affect other tests
webnotes.conn.sql("""delete from `tabEmployee Leave Approver`""")
def _clear_roles(self):
webnotes.conn.sql("""delete from `tabUserRole` where parent in
("test@example.com", "test1@example.com", "test2@example.com")""")
@@ -162,10 +165,10 @@ class TestLeaveApplication(unittest.TestCase):
from webnotes.model.bean import BeanPermissionError
self.assertRaises(BeanPermissionError, application.submit)
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
"_T-Employee-0001")
def _test_leave_approval_valid_leave_approver_insert(self):
self._clear_applications()
self._add_employee_leave_approver("_T-Employee-0001", "test2@example.com")

View File

@@ -8,23 +8,23 @@ from hr.doctype.leave_block_list.leave_block_list import get_applicable_block_da
class TestLeaveBlockList(unittest.TestCase):
def tearDown(self):
webnotes.session.user = "Administrator"
webnotes.set_user("Administrator")
def test_get_applicable_block_dates(self):
webnotes.session.user = "test@example.com"
webnotes.set_user("test@example.com")
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",
"_Test Leave Block List")
self.assertTrue("2013-01-02" in
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
def test_get_applicable_block_dates_for_allowed_user(self):
webnotes.session.user = "test1@example.com"
webnotes.set_user("test1@example.com")
webnotes.conn.set_value("Department", "_Test Department 1", "leave_block_list",
"_Test Leave Block List")
self.assertEquals([], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
def test_get_applicable_block_dates_all_lists(self):
webnotes.session.user = "test1@example.com"
webnotes.set_user("test1@example.com")
webnotes.conn.set_value("Department", "_Test Department 1", "leave_block_list",
"_Test Leave Block List")
self.assertTrue("2013-01-02" in