[Fix] Attendance tool
This commit is contained in:
parent
550fc695f1
commit
c7f8b82fff
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, add_days, date_diff
|
from frappe.utils import cstr, add_days, date_diff, getdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils.csvutils import UnicodeWriter
|
from frappe.utils.csvutils import UnicodeWriter
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
@ -48,8 +48,9 @@ def add_data(w, args):
|
|||||||
for employee in employees:
|
for employee in employees:
|
||||||
existing_attendance = {}
|
existing_attendance = {}
|
||||||
if existing_attendance_records \
|
if existing_attendance_records \
|
||||||
and tuple([date, employee.name]) in existing_attendance_records:
|
and tuple([getdate(date), employee.name]) in existing_attendance_records:
|
||||||
existing_attendance = existing_attendance_records[tuple([date, employee.name])]
|
existing_attendance = existing_attendance_records[tuple([getdate(date), employee.name])]
|
||||||
|
|
||||||
row = [
|
row = [
|
||||||
existing_attendance and existing_attendance.name or "",
|
existing_attendance and existing_attendance.name or "",
|
||||||
employee.name, employee.employee_name, date,
|
employee.name, employee.employee_name, date,
|
||||||
@ -114,6 +115,7 @@ def upload():
|
|||||||
if not row: continue
|
if not row: continue
|
||||||
row_idx = i + 5
|
row_idx = i + 5
|
||||||
d = frappe._dict(zip(columns, row))
|
d = frappe._dict(zip(columns, row))
|
||||||
|
|
||||||
d["doctype"] = "Attendance"
|
d["doctype"] = "Attendance"
|
||||||
if d.name:
|
if d.name:
|
||||||
d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus")
|
d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus")
|
||||||
@ -121,6 +123,8 @@ def upload():
|
|||||||
try:
|
try:
|
||||||
check_record(d)
|
check_record(d)
|
||||||
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
|
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error = True
|
error = True
|
||||||
ret.append('Error for row (#%d) %s : %s' % (row_idx,
|
ret.append('Error for row (#%d) %s : %s' % (row_idx,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user