diff --git a/addons/hr_attendance/report/attendance_by_month.py b/addons/hr_attendance/report/attendance_by_month.py index 7087256646e..069c1adad88 100644 --- a/addons/hr_attendance/report/attendance_by_month.py +++ b/addons/hr_attendance/report/attendance_by_month.py @@ -85,14 +85,13 @@ 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': - tot_tim = (str(float((dt - ldt).seconds)/3600)) - hrs = int(tot_tim.split('.')[0]) - mints = int(tot_tim.split('.')[1]) - tot_min = (int(mints * 60) / 10) - if tot_min < (10) or tot_tim < ('0.09'): - wh += float((str(hrs))+ '.' + '0' +(str(tot_min))) - else: - wh += float((str(hrs))+ '.' + (str(tot_min))) + tot_time = (dt - ldt).seconds + hrs, remainder = divmod(tot_time, 3600) + min, sec = divmod(remainder, 60) + if min < 10: + wh += float((str(hrs))+ '.' + '0' +(str(min))) + else: + wh += float((str(hrs))+ '.' + (str(min))) else: ldt = dt # Week xml representation diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py index 1ca7eeb584a..77196c4f0ae 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 @@ -80,10 +80,18 @@ class report_custom(report_rml): attendances.append({'name': n_monday.strftime('%Y-%m-%d %H:%M:%S'), 'action': 'sign_out'}) # sum up the attendances' durations ldt = None + wh = 0.0 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) + tot_time = (dt - ldt).seconds + hrs, remainder = divmod(tot_time, 3600) + min, sec = divmod(remainder, 60) + if min < 10: + wh = float((str(hrs))+ '.' + '0' +(str(min))) + else: + wh = float((str(hrs))+ '.' + (str(min))) + week_wh[ldt.date().weekday()] = week_wh.get(ldt.date().weekday(), 0) + round(wh,2) else: ldt = dt @@ -92,10 +100,10 @@ class report_custom(report_rml): for idx in range(7): week_repr.append('<%s>' % num2day[idx]) if idx in week_wh: - week_repr.append('%sh%02d' % to_hour(week_wh[idx])) + week_repr.append('%s' %(week_wh[idx])) week_repr.append('' % num2day[idx]) week_repr.append('') - week_repr.append('%sh%02d' % to_hour(reduce(lambda x,y:x+y, week_wh.values(), 0))) + week_repr.append('%s' % sum(week_wh.values())) week_repr.append('') week_repr.append('') if len(week_repr) > 21: # 21 = minimal length of week_repr