diff --git a/addons/hr_attendance/report/attendance_by_month.py b/addons/hr_attendance/report/attendance_by_month.py index ced701ac661..2b708434317 100644 --- a/addons/hr_attendance/report/attendance_by_month.py +++ b/addons/hr_attendance/report/attendance_by_month.py @@ -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 = '%s' % ((today - month).days+1, round(wh,2)) + wh = hour2str(wh) + today_xml = '%s' % ((today - month).days+1, (wh)) dy=(today - month).days+1 days_xml.append(today_xml) today, tomor = tomor, tomor + one_day diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py index 1ca7eeb584a..7adfe98ef13 100644 --- a/addons/hr_attendance/report/timesheet.py +++ b/addons/hr_attendance/report/timesheet.py @@ -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