[Openerp-community-reviewer] [Merge] lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet

2014-07-29 Thread Alex Comba - Agile BG
The proposal to merge 
lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into 
lp:hr-timesheet has been updated.

Status: Needs review = Work in progress

For more details, see:
https://code.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone/+merge/221374
-- 
https://code.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone/+merge/221374
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch 
lp:hr-timesheet.

-- 
Mailing list: https://launchpad.net/~openerp-community-reviewer
Post to : openerp-community-reviewer@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-community-reviewer
More help   : https://help.launchpad.net/ListHelp


[Openerp-community-reviewer] [Merge] lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet

2014-05-29 Thread Lorenzo Battistini - Agile BG
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 +
+++ hr_attendance_analysis/wizard/print_calendar_report.py	2014-05-29 13:03:53 +
@@ -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

-- 
Mailing list: https://launchpad.net/~openerp-community-reviewer
Post to : openerp-community-reviewer@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-community-reviewer
More help   : https://help.launchpad.net/ListHelp


[Openerp-community-reviewer] [Merge] lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet

2014-05-29 Thread Lorenzo Battistini - Agile BG
You have been requested to review the proposed merge of 
lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into 
lp:hr-timesheet.

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 +
+++ hr_attendance_analysis/wizard/print_calendar_report.py	2014-05-29 13:03:53 +
@@ -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

-- 
Mailing list: https://launchpad.net/~openerp-community-reviewer
Post to : openerp-community-reviewer@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-community-reviewer
More help   : https://help.launchpad.net/ListHelp


Re: [Openerp-community-reviewer] [Merge] lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone into lp:hr-timesheet

2014-05-29 Thread Pedro Manuel Baeza
Review: Needs Information code review

Hi, Lorenzo,

I think your fix has a problem with times that after been converted to correct 
timezone change its date. For example: 29/05/2014 00:12 GMT+2  28/05/2014 
22:12 UTC.

Regards.
-- 
https://code.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-report-timezone/+merge/221374
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch 
lp:hr-timesheet.

-- 
Mailing list: https://launchpad.net/~openerp-community-reviewer
Post to : openerp-community-reviewer@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-community-reviewer
More help   : https://help.launchpad.net/ListHelp