[MERGE] hr_attendance: v6 hr_attendance - time is rounded to hour
bzr revid: mra@mra-laptop-20110207105145-pbtu64jtnwdhl69h
This commit is contained in:
@@ -34,10 +34,10 @@ from tools import ustr
|
||||
one_day = relativedelta(days=1)
|
||||
month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
#def hour2str(h):
|
||||
# hours = int(h)
|
||||
# minutes = int(round((h - hours) * 60, 0))
|
||||
# return '%02dh%02d' % (hours, minutes)
|
||||
def hour2str(h):
|
||||
hours = int(h)
|
||||
minutes = int(round((h - hours) * 60, 0))
|
||||
return '%02dh%02d' % (hours, minutes)
|
||||
|
||||
def lengthmonth(year, month):
|
||||
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
|
||||
@@ -85,12 +85,12 @@ class report_custom(report_rml):
|
||||
for att in attendences:
|
||||
dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
if ldt and att['action'] == 'sign_out':
|
||||
wh += (dt - ldt).seconds/60/60
|
||||
wh += (float((dt - ldt).seconds)/60/60)
|
||||
else:
|
||||
ldt = dt
|
||||
# Week xml representation
|
||||
# wh = hour2str(wh)
|
||||
today_xml = '<day num="%s"><wh>%s</wh></day>' % ((today - month).days+1, round(wh,2))
|
||||
wh = hour2str(wh)
|
||||
today_xml = '<day num="%s"><wh>%s</wh></day>' % ((today - month).days+1, (wh))
|
||||
dy=(today - month).days+1
|
||||
days_xml.append(today_xml)
|
||||
today, tomor = tomor, tomor + one_day
|
||||
|
||||
@@ -43,7 +43,7 @@ class report_custom(report_rml):
|
||||
end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d')
|
||||
first_monday = start_date - relativedelta(days=start_date.date().weekday())
|
||||
last_monday = end_date + relativedelta(days=7 - end_date.date().weekday())
|
||||
|
||||
|
||||
if last_monday < first_monday:
|
||||
first_monday, last_monday = last_monday, first_monday
|
||||
|
||||
@@ -83,7 +83,7 @@ class report_custom(report_rml):
|
||||
for att in attendances:
|
||||
dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
if ldt and att['action'] == 'sign_out':
|
||||
week_wh[ldt.date().weekday()] = week_wh.get(ldt.date().weekday(), 0) + ((dt - ldt).seconds/3600)
|
||||
week_wh[ldt.date().weekday()] = week_wh.get(ldt.date().weekday(), 0) + (float((dt - ldt).seconds)/3600)
|
||||
else:
|
||||
ldt = dt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user