From 8d8ce8454e9e24e634467daac6dc4f30ce2bcfd0 Mon Sep 17 00:00:00 2001
From: Numerigraphe - Lionel Sausin <ls@numerigraphe.fr>
Date: Fri, 6 Feb 2009 11:11:10 +0100
Subject: [PATCH] Fixed timestamp formatting in attendance reports. Added
 default value for attendance report wizard.

bzr revid: ls@numerigraphe.fr-20090206101110-e6bnbv6111mp11kh
---
 addons/hr_attendance/report/bymonth.py       |  2 +-
 addons/hr_attendance/report/timesheet.py     |  2 +-
 addons/hr_attendance/wizard/print_bymonth.py | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/addons/hr_attendance/report/bymonth.py b/addons/hr_attendance/report/bymonth.py
index bce9bd4d3ce9..d0715b4b66da 100644
--- a/addons/hr_attendance/report/bymonth.py
+++ b/addons/hr_attendance/report/bymonth.py
@@ -65,7 +65,7 @@ class report_custom(report_rml):
                 where att.name between %s and %s and emp.id = %s
                 order by att.name
                 '''
-                cr.execute(sql, (today, tomor, employee_id))
+                cr.execute(sql, (today.strftime('%Y-%m-%d %H:%M:%S'), tomor.strftime('%Y-%m-%d %H:%M:%S'), employee_id))
                 attendences = cr.dictfetchall()
                 wh = 0
                 # Fake sign ins/outs at week ends, to take attendances across week ends into account
diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py
index 7e2a14ade623..feec7743370e 100644
--- a/addons/hr_attendance/report/timesheet.py
+++ b/addons/hr_attendance/report/timesheet.py
@@ -75,7 +75,7 @@ class report_custom(report_rml):
 				order by att.name
 				'''
 				for idx in range(7):
-					cr.execute(sql, (monday, monday + DateTime.RelativeDateTime(days=idx+1), employee_id))
+					cr.execute(sql, (monday.strftime('%Y-%m-%d %H:%M:%S'), (monday + DateTime.RelativeDateTime(days=idx+1)).strftime('%Y-%m-%d %H:%M:%S'), employee_id))
 					attendances = cr.dictfetchall()
 					week_wh = {}
 	                # Fake sign ins/outs at week ends, to take attendances across week ends into account
diff --git a/addons/hr_attendance/wizard/print_bymonth.py b/addons/hr_attendance/wizard/print_bymonth.py
index 0261d94f594b..4e28055bcdc0 100644
--- a/addons/hr_attendance/wizard/print_bymonth.py
+++ b/addons/hr_attendance/wizard/print_bymonth.py
@@ -31,15 +31,26 @@ _date_form = '''<?xml version="1.0"?>
 </form>'''
 
 _date_fields = {
-    'month' : {'string' : 'Month', 'type' : 'selection', 'selection' : [(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], 'required':True },
-    'year' : {'string' : 'Year', 'type' : 'integer', 'required':True, 'default' : lambda *a: time.gmtime()[0]},
+    'month' : {
+               'string' : 'Month',
+               'type' : 'selection',
+               'selection' : [(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')],
+               'required':True,
+               'default' : lambda * a: time.gmtime()[1]
+               },
+    'year' : {
+              'string' : 'Year',
+              'type' : 'integer',
+              'required':True,
+              'default' : lambda * a: time.gmtime()[0]
+              },
 }
 
 class wiz_bymonth(wizard.interface):
     states = {
         'init': {
             'actions': [],
-            'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Timesheet'),('end','Cancel')]}
+            'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print', 'Print Timesheet'), ('end', 'Cancel')]}
         },
         'print': {
             'actions': [],
-- 
GitLab