[merge] merge with master

This commit is contained in:
Rushabh Mehta
2013-05-24 16:09:13 +05:30
120 changed files with 1431 additions and 712 deletions

View File

@@ -18,7 +18,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, nowdate
from webnotes.model.doc import make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
@@ -28,9 +27,6 @@ class DocType:
self.doc = doc
self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_emp_name(self):
return {
"employee_name": webnotes.conn.get_value("Employee",

View File

@@ -36,7 +36,7 @@ class DocType:
if ret[0][0]=='Naming Series':
self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif ret[0][0]=='Employee Number':
self.doc.name = make_autoname(self.doc.employee_number)
self.doc.name = self.doc.employee_number
self.doc.employee = self.doc.name
@@ -80,7 +80,7 @@ class DocType:
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
where parent=%s""", self.doc.user_id):
from webnotes.profile import add_role
add_role(self.doc.user_id, "HR User")
add_role(self.doc.user_id, "Employee")
profile_wrapper = webnotes.bean("Profile", self.doc.user_id)

View File

@@ -335,15 +335,22 @@ def add_holidays(events, start, end, employee, company):
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
txt = "%" + cstr(txt) + "%"
return webnotes.conn.sql("""select name, employee_name from `tabEmployee` emp
if "Leave Approver" in webnotes.user.get_roles():
condition = """and (exists(select ela.name from `tabEmployee Leave Approver` ela
where ela.parent=`tabEmployee`.name and ela.leave_approver= "%s") or
not exists(select ela.name from `tabEmployee Leave Approver` ela
where ela.parent=`tabEmployee`.name)
or user_id = "%s")""" % (webnotes.session.user, webnotes.session.user)
else:
from webnotes.widgets.reportview import build_match_conditions
condition = build_match_conditions("Employee")
condition = ("and " + condition) if condition else ""
return webnotes.conn.sql("""select name, employee_name from `tabEmployee`
where status = 'Active' and docstatus < 2 and
(`%s` like %s or employee_name like %s) and
(exists(select ela.name from `tabEmployee Leave Approver` ela
where ela.parent=emp.name and ela.leave_approver=%s) or
not exists(select ela.name from `tabEmployee Leave Approver` ela where ela.parent=emp.name)
or user_id = %s)
(`%s` like %s or employee_name like %s) %s
order by
case when name like %s then 0 else 1 end,
case when employee_name like %s then 0 else 1 end,
name limit %s, %s""" % tuple([searchfield] + ["%s"]*8),
(txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len))
name limit %s, %s""" % tuple([searchfield] + ["%s"]*2 + [condition] + ["%s"]*4),
(txt, txt, txt, txt, start, page_len))

View File

@@ -75,7 +75,6 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
r.messages = ["<h4 style='color:green'>Import Successful!</h4>"].
concat(r.messages)
}
console.log(r.messages);
$.each(r.messages, function(i, v) {
var $p = $('<p>').html(v).appendTo($log_wrapper);

View File

@@ -100,7 +100,6 @@ def get_naming_series():
def upload():
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
from webnotes.modules import scrub
from core.page.data_import_tool.data_import_tool import check_record, import_doc
rows = read_csv_content_from_uploaded_file()
if not rows:
@@ -112,6 +111,9 @@ def upload():
ret = []
error = False
from webnotes.utils.datautils import check_record, import_doc
doctype_dl = webnotes.get_doctype("Attendance")
for i, row in enumerate(rows[5:]):
if not row: continue
row_idx = i + 5
@@ -121,7 +123,7 @@ def upload():
d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")
try:
check_record(d)
check_record(d, doctype_dl=doctype_dl)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e:
error = True