openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #07015
[Merge] lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet
Lorenzo Battistini - Agile BG has proposed merging lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet.
Requested reviews:
HR Core Editors (hr-core-editors)
Alex Comba - Agile BG (tafaru)
For more details, see:
https://code.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone/+merge/221374
[FIX] hr_attendance_analysis
using correct timezone to print the sign in/out time
--
https://code.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone/+merge/221374
Your team HR Core Editors is requested to review the proposed merge of lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet.
=== modified file 'hr_attendance_analysis/wizard/print_calendar_report.py'
--- hr_attendance_analysis/wizard/print_calendar_report.py 2013-11-19 13:32:00 +0000
+++ hr_attendance_analysis/wizard/print_calendar_report.py 2014-05-29 13:03:53 +0000
@@ -25,6 +25,7 @@
from datetime import *
import math
import calendar
+import pytz
class wizard_calendar_report(orm.TransientModel):
@@ -86,6 +87,8 @@
employee_ids=form['employee_ids']
delta = to_date - from_date
max_number_of_attendances_per_day = 0
+ active_tz = pytz.timezone(
+ context.get("tz","UTC") if context else "UTC")
for employee_id in employee_ids:
employee_id = str(employee_id)
@@ -136,14 +139,24 @@
count = 1
for attendance in sorted(attendance_pool.browse(cr, uid, attendance_ids, context=context),
key=lambda x: x['name']):
- days_by_employee[employee_id][str_current_date][
- 'signin_'+str(count)] = attendance.name[11:16]
- days_by_employee[employee_id][str_current_date][
- 'signout_'+str(count)] = attendance.end_datetime[11:16]
+
+ attendance_start = datetime.strptime(
+ attendance.name, '%Y-%m-%d %H:%M:%S'
+ ).replace(tzinfo=pytz.utc).astimezone(active_tz)
+ attendance_end = datetime.strptime(
+ attendance.end_datetime, '%Y-%m-%d %H:%M:%S'
+ ).replace(tzinfo=pytz.utc).astimezone(active_tz)
+
+ days_by_employee[employee_id][str_current_date][
+ 'signin_'+str(count)] = '%s:%s' % (
+ attendance_start.hour, attendance_start.minute)
+ days_by_employee[employee_id][str_current_date][
+ 'signout_'+str(count)] = '%s:%s' % (
+ attendance_end.hour, attendance_end.minute)
count += 1
if len(attendance_ids) > max_number_of_attendances_per_day:
max_number_of_attendances_per_day = len(attendance_ids)
-
+
days_by_employee[employee_id][str_current_date][
'attendances'
] = current_total_attendances
References