From 252cb556913ce2e5998c89512f0da6dde2a20025 Mon Sep 17 00:00:00 2001
From: "rch (Open ERP)" <>
Date: Tue, 14 Sep 2010 18:50:35 +0530
Subject: [PATCH] [IMP/ADD]: Header in hr_attendance xsl report - 'Attendance
By Month' with saperate header template for xsl landscape rport. Add
FormatLang in header's date of hr reports.
bzr revid: rch_open_erp-20100914132035-ny793gedcmah1pem
---
.../report/attendance_by_month.py | 15 ++++++-
addons/hr_attendance/report/bymonth.xsl | 25 +++---------
.../report/hr_custom_default.xsl | 40 +++++++++++++++++++
addons/hr_attendance/report/hr_custom_rml.xsl | 37 +++++++++++++++++
.../report/holidays_summary_report.py | 5 ++-
addons/hr_timesheet/report/user_timesheet.py | 5 ++-
addons/hr_timesheet/report/users_timesheet.py | 6 ++-
7 files changed, 109 insertions(+), 24 deletions(-)
create mode 100644 addons/hr_attendance/report/hr_custom_default.xsl
create mode 100644 addons/hr_attendance/report/hr_custom_rml.xsl
diff --git a/addons/hr_attendance/report/attendance_by_month.py b/addons/hr_attendance/report/attendance_by_month.py
index f4ee7035136..f718c4f2333 100644
--- a/addons/hr_attendance/report/attendance_by_month.py
+++ b/addons/hr_attendance/report/attendance_by_month.py
@@ -29,6 +29,8 @@ import pooler
from report.interface import report_rml
from report.interface import toxml
+from report import report_sxw
+
one_day = DateTime.RelativeDateTime(days=1)
month2name = [0, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@@ -85,11 +87,22 @@ class report_custom(report_rml):
days_xml.append(today_xml)
today, tomor = tomor, tomor + one_day
user_xml.append(user_repr % '\n'.join(days_xml))
+
+ rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
+ rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
+ header_xml = '''
+
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
+
xml = '''
%s
+ %s
- ''' % '\n'.join(user_xml)
+ ''' % (header_xml,'\n'.join(user_xml))
return xml
report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')
diff --git a/addons/hr_attendance/report/bymonth.xsl b/addons/hr_attendance/report/bymonth.xsl
index ea4e849cb07..42e52ce474a 100644
--- a/addons/hr_attendance/report/bymonth.xsl
+++ b/addons/hr_attendance/report/bymonth.xsl
@@ -3,23 +3,15 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -33,15 +25,10 @@
-
-
-
-
-
-
-
+
+
Attendance By Month
+
+
+
+
+
+
+
+
+
+
+
+ /
+
+ 1.3cm 19.3cm 28.5cm 19.3cm
+
+
+
+
+
+
+
+
+
+
+
+ /
+
+ 1.3cm 19.3cm 28.5cm 19.3cm
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/hr_attendance/report/hr_custom_rml.xsl b/addons/hr_attendance/report/hr_custom_rml.xsl
new file mode 100644
index 00000000000..64a4894613a
--- /dev/null
+++ b/addons/hr_attendance/report/hr_custom_rml.xsl
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py
index 323f23404d4..03d30f367ac 100644
--- a/addons/hr_holidays/report/holidays_summary_report.py
+++ b/addons/hr_holidays/report/holidays_summary_report.py
@@ -28,6 +28,7 @@ from report.interface import toxml
import pooler
import time
+from report import report_sxw
def lengthmonth(year, month):
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
@@ -235,12 +236,14 @@ class report_custom(report_rml):
emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)
row_id = row_id +1
+ rpt_obj = pooler.get_pool(cr.dbname).get('hr.holidays')
+ rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
header_xml = '''
- ''' % (time.strftime('%m/%d/%Y %H:%M'),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
# Computing the xml
xml='''
diff --git a/addons/hr_timesheet/report/user_timesheet.py b/addons/hr_timesheet/report/user_timesheet.py
index f4428c5a045..8cf255c9b7f 100644
--- a/addons/hr_timesheet/report/user_timesheet.py
+++ b/addons/hr_timesheet/report/user_timesheet.py
@@ -26,6 +26,7 @@ from report.interface import toxml
from tools.translate import _
import time
import pooler
+from report import report_sxw
def lengthmonth(year, month):
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
@@ -76,12 +77,14 @@ class report_custom(report_rml):
%.2f
'''
+ rpt_obj = pooler.get_pool(cr.dbname).get('hr.holidays')
+ rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
header_xml = '''
- ''' % (time.strftime('%m/%d/%Y %H:%M'),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
account_xml = []
for account, telems in accounts.iteritems():
diff --git a/addons/hr_timesheet/report/users_timesheet.py b/addons/hr_timesheet/report/users_timesheet.py
index 9fd2f93e0be..0198994728c 100644
--- a/addons/hr_timesheet/report/users_timesheet.py
+++ b/addons/hr_timesheet/report/users_timesheet.py
@@ -25,6 +25,7 @@ from report.interface import toxml
import time
import pooler
from tools.translate import _
+from report import report_sxw
def lengthmonth(year, month):
@@ -96,13 +97,14 @@ class report_custom(report_rml):
# Computing the xml
#Without this, report don't show non-ascii characters (TO CHECK)
date_xml = '\n'.join(date_xml)
-
+ rpt_obj = pooler.get_pool(cr.dbname).get('hr.holidays')
+ rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
header_xml = '''
- ''' % (time.strftime('%m/%d/%Y %H:%M'),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
xml='''