Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py
index 4360c7e..d08da1a 100644
--- a/hr/doctype/employee/employee.py
+++ b/hr/doctype/employee/employee.py
@@ -70,6 +70,11 @@
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
+
+ # add employee role if missing
+ if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
+ where parent=%s""", self.doc.user_id):
+ webnotes.get_obj("Profile", self.doc.user_id).add_role("Employee")
def validate_date(self):
import datetime
@@ -134,4 +139,15 @@
"status": "Active",
"company": "_Test Company",
"user_id": "test@erpnext.com"
+}],
+[{
+ "doctype":"Employee",
+ "employee_name": "_Test Employee 1",
+ "naming_series": "_T-Employee-",
+ "date_of_joining": "2010-01-01",
+ "date_of_birth": "1980-01-01",
+ "gender": "Male",
+ "status": "Active",
+ "company": "_Test Company",
+ "user_id": "test1@erpnext.com"
}]]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list/holiday_block_list.py b/hr/doctype/holiday_block_list/holiday_block_list.py
index 4ebe49e..619f373 100644
--- a/hr/doctype/holiday_block_list/holiday_block_list.py
+++ b/hr/doctype/holiday_block_list/holiday_block_list.py
@@ -31,4 +31,11 @@
"parentfield": "holiday_block_list_dates",
"block_date": "2013-01-02",
"reason": "First work day"
- }]]
\ No newline at end of file
+ }, {
+ "doctype": "Holiday Block List Allow",
+ "parent": "_Test Holiday Block List",
+ "parenttype": "Holiday Block List",
+ "parentfield": "holiday_block_list_allowed",
+ "allow_user": "test1@erpnext.com",
+ }
+ ]]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list/holiday_block_list.txt b/hr/doctype/holiday_block_list/holiday_block_list.txt
index 732e783..31b2f98 100644
--- a/hr/doctype/holiday_block_list/holiday_block_list.txt
+++ b/hr/doctype/holiday_block_list/holiday_block_list.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-02-04 15:31:29",
"docstatus": 0,
- "modified": "2013-02-04 15:38:57",
+ "modified": "2013-02-06 14:39:09",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -54,6 +54,13 @@
"reqd": 1
},
{
+ "description": "Stop users from making Leave Applications on following days.",
+ "doctype": "DocField",
+ "fieldname": "block_days",
+ "fieldtype": "Section Break",
+ "label": "Block Days"
+ },
+ {
"doctype": "DocField",
"fieldname": "holiday_block_list_dates",
"fieldtype": "Table",
@@ -61,6 +68,20 @@
"options": "Holiday Block List Date"
},
{
+ "description": "Allow the following users to make Leave Applications for block days.",
+ "doctype": "DocField",
+ "fieldname": "allow_list",
+ "fieldtype": "Section Break",
+ "label": "Allow Users"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "holiday_block_list_allowed",
+ "fieldtype": "Table",
+ "label": "Holiday Block List Allowed",
+ "options": "Holiday Block List Allow"
+ },
+ {
"doctype": "DocPerm"
}
]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list_allow/__init__.py b/hr/doctype/holiday_block_list_allow/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hr/doctype/holiday_block_list_allow/__init__.py
diff --git a/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.py b/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.py
new file mode 100644
index 0000000..928aa9f
--- /dev/null
+++ b/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.py
@@ -0,0 +1,8 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.txt b/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.txt
new file mode 100644
index 0000000..bdbd2a0
--- /dev/null
+++ b/hr/doctype/holiday_block_list_allow/holiday_block_list_allow.txt
@@ -0,0 +1,35 @@
+[
+ {
+ "creation": "2013-02-06 14:31:03",
+ "docstatus": 0,
+ "modified": "2013-02-06 14:31:03",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "DocType",
+ "istable": 1,
+ "module": "HR",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "allow_user",
+ "fieldtype": "Link",
+ "label": "Allow User",
+ "name": "__common__",
+ "options": "Profile",
+ "parent": "Holiday Block List Allow",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "width": "200px"
+ },
+ {
+ "doctype": "DocType",
+ "name": "Holiday Block List Allow"
+ },
+ {
+ "doctype": "DocField"
+ }
+]
\ No newline at end of file
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index 8c7124e..cab8f17 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -53,6 +53,8 @@
if department:
block_list = webnotes.conn.get_value("Department", department, "holiday_block_list")
if block_list:
+ if self.is_user_in_allow_list(block_list):
+ return
for d in webnotes.conn.sql("""select block_date, reason from
`tabHoliday Block List Date` where parent=%s""", block_list, as_dict=1):
block_date = getdate(d.block_date)
@@ -61,6 +63,10 @@
+ ": " + formatdate(d.block_date) + _(" Reason: ") + d.reason)
raise LeaveDayBlockedError
+ def is_user_in_allow_list(self, block_list):
+ return webnotes.session.user in webnotes.conn.sql_list("""select allow_user
+ from `tabHoliday Block List Allow` where parent=%s""", block_list)
+
def get_holidays(self):
tot_hol = webnotes.conn.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
@@ -147,23 +153,4 @@
def is_lwp(leave_type):
lwp = webnotes.conn.sql("select is_lwp from `tabLeave Type` where name = %s", leave_type)
- return lwp and cint(lwp[0][0]) or 0
-
-test_records = [
- [{
- "doctype": "Leave Allocation",
- "leave_type": "_Test Leave Type",
- "fiscal_year": "_Test Fiscal Year",
- "employee":"_T-Employee-0001",
- "new_leaves_allocated": 15,
- "docstatus": 1
- }],
- [{
- "doctype": "Leave Application",
- "leave_type": "_Test Leave Type",
- "from_date": "2013-05-01",
- "to_date": "2013-05-05",
- "posting_date": "2013-01-02",
- "fiscal_year": "_Test Fiscal Year",
- "employee": "_T-Employee-0001"
- }]]
\ No newline at end of file
+ return lwp and cint(lwp[0][0]) or 0
\ No newline at end of file
diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py
index fac3685..e485289 100644
--- a/hr/doctype/leave_application/test_leave_application.py
+++ b/hr/doctype/leave_application/test_leave_application.py
@@ -1,26 +1,50 @@
- import sys
- import unittest
+import sys
+import unittest
- from hr.doctype.leave_application.leave_application import test_records, LeaveDayBlockedError
+from hr.doctype.leave_application.leave_application import LeaveDayBlockedError
- class TestLeaveApplication(unittest.TestCase):
- def setUp(self):
- from webnotes.test_runner import make_test_records
- make_test_records("Leave Application")
-
- def test_block_list(self):
- import webnotes
- webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
- "_Test Department with Block List")
-
- application = webnotes.model_wrapper(test_records[1])
- application.doc.from_date = "2013-01-01"
- application.doc.to_date = "2013-01-05"
- self.assertRaises(LeaveDayBlockedError, application.insert)
-
- if __name__=="__main__":
- sys.path.extend(["app", "lib"])
+class TestLeaveApplication(unittest.TestCase):
+ def test_block_list(self):
import webnotes
- webnotes.connect()
- unittest.main()
-
\ No newline at end of file
+ webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
+ "_Test Department with Block List")
+
+ application = webnotes.model_wrapper(test_records[1])
+ application.doc.from_date = "2013-01-01"
+ application.doc.to_date = "2013-01-05"
+ self.assertRaises(LeaveDayBlockedError, application.insert)
+
+ webnotes.session.user = "test1@erpnext.com"
+ webnotes.get_obj("Profile", "test1@erpnext.com").add_role("HR User")
+ self.assertTrue(application.insert())
+
+
+test_records = [
+ [{
+ "doctype": "Leave Allocation",
+ "leave_type": "_Test Leave Type",
+ "fiscal_year": "_Test Fiscal Year",
+ "employee":"_T-Employee-0001",
+ "new_leaves_allocated": 15,
+ "docstatus": 1
+ }],
+ [{
+ "doctype": "Leave Application",
+ "leave_type": "_Test Leave Type",
+ "from_date": "2013-05-01",
+ "to_date": "2013-05-05",
+ "posting_date": "2013-01-02",
+ "fiscal_year": "_Test Fiscal Year",
+ "employee": "_T-Employee-0001"
+ }]]
+
+if __name__=="__main__":
+ sys.path.extend(["app", "lib"])
+ import webnotes
+ webnotes.connect()
+
+ from webnotes.test_runner import make_test_records
+ make_test_records("Leave Application")
+
+ unittest.main()
+
diff --git a/public/js/toolbar.js b/public/js/toolbar.js
index fd7109a..8fd3d98 100644
--- a/public/js/toolbar.js
+++ b/public/js/toolbar.js
@@ -52,7 +52,7 @@
$('<li class="dropdown">\
<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
title="'+wn._("Modules")+'"\
- onclick="return false;"><i class="icon-th"></i> <b class="caret"></b></a>\
+ onclick="return false;"><i class="icon-th"></i></a>\
<ul class="dropdown-menu modules">\
</ul>\
</li>').prependTo('.navbar .nav:first');