[IMP/ADD]: Header in hr_timesheet xsl reports with saterate template for xsl landscape rport.

bzr revid: rch_open_erp-20100914114055-s1ap8zky5sm6kcbe
This commit is contained in:
rch (Open ERP)
2010-09-14 17:10:55 +05:30
parent 6023ac2d6e
commit 433ce6f932
6 changed files with 117 additions and 44 deletions
@@ -0,0 +1,40 @@
<?xml version = '1.0' encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template name="first_page_graphics_corporation">
<!--logo-->
<fill color="black"/>
<stroke color="black"/>
<setFont name="DejaVu Sans" size="8"/>
<drawString x="1.3cm" y="19.5cm"><xsl:value-of select="//report/header/date"/></drawString>
<setFont name="DejaVu Sans Bold" size="10"/>
<drawString x="13.8cm" y="19.5cm"><xsl:value-of select="//report/header/company"/></drawString>
<setFont name="DejaVu Sans" size="8"/>
<drawRightString x="28.4cm" y="19.5cm"><pageNumber/> / </drawRightString>
<stroke color="#000000"/>
<lines>1.3cm 19.3cm 28.5cm 19.3cm</lines>
</xsl:template>
<xsl:template name="other_pages_graphics_corporation">
<!--logo-->
<fill color="black"/>
<stroke color="black"/>
<setFont name="DejaVu Sans" size="8"/>
<drawString x="1.3cm" y="19.5cm"><xsl:value-of select="//report/header/date"/></drawString>
<setFont name="DejaVu Sans Bold" size="10"/>
<drawString x="27.8cm" y="19.5cm"><xsl:value-of select="//report/header/company"/></drawString>
<setFont name="DejaVu Sans" size="8"/>
<drawRightString x="28.4cm" y="19.5cm"><pageNumber/> / </drawRightString>
<stroke color="#000000"/>
<lines>1.3cm 19.3cm 28.5cm 19.3cm</lines>
</xsl:template>
<xsl:template name="first_page_frames">
<frame id="col1" x1="2.0cm" y1="2.5cm" width="24.7cm" height="17cm"/>
</xsl:template>
<xsl:template name="other_pages_frames">
<frame id="col1" x1="2.0cm" y1="2.5cm" width="24.7cm" height="17cm"/>
</xsl:template>
</xsl:stylesheet>
+37
View File
@@ -0,0 +1,37 @@
<?xml version = '1.0' encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template name="first_page_graphics_report"/>
<xsl:template name="other_pages_graphics_report"/>
<xsl:template name="rml">
<document filename="example.pdf">
<template pageSize="29.7cm,21cm" leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Timesheets" author="Generated by Open ERP, Fabien Pinckaers" allowSplitting="20">
<pageTemplate id="first_page">
<pageGraphics>
<xsl:call-template name="first_page_graphics_corporation"/>
</pageGraphics>
<xsl:call-template name="first_page_frames"/>
</pageTemplate>
<pageTemplate id="other_pages">
<pageGraphics>
<xsl:call-template name="other_pages_graphics_corporation"/>
</pageGraphics>
<xsl:call-template name="other_pages_frames"/>
</pageTemplate>
</template>
<stylesheet>
<xsl:call-template name="stylesheet"/>
</stylesheet>
<story>
<xsl:call-template name="story"/>
</story>
</document>
</xsl:template>
</xsl:stylesheet>
+15 -7
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,16 +15,16 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import datetime
from report.interface import report_rml
from report.interface import toxml
from report.interface import toxml
from tools.translate import _
import time
import pooler
def lengthmonth(year, month):
@@ -52,7 +52,7 @@ class report_custom(report_rml):
date_xml.append('</days>')
date_xml.append('<cols>2.5cm%s,2cm</cols>\n' % (',0.7cm' * lengthmonth(som.year, som.month)))
# Computing the attendence by analytical account
cr.execute(
"select line.date, (unit_amount * unit.factor) as amount, account_id, account.name "\
@@ -70,12 +70,19 @@ class report_custom(report_rml):
day = int(presence['date'][-2:])
account = accounts.setdefault((presence['account_id'], presence['name']), {})
account[day] = account.get(day, 0.0) + presence['amount']
xml = '''
<time-element date="%s">
<amount>%.2f</amount>
</time-element>
'''
header_xml = '''
<header>
<date>%s</date>
<company>%s</company>
</header>
''' % (time.strftime('%m/%d/%Y %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():
aid, aname = account
@@ -93,10 +100,11 @@ class report_custom(report_rml):
# Computing the xml
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
<report>
%s
<employee>%s</employee>
%s
</report>
''' % (toxml(emp), '\n'.join(date_xml) + '\n'.join(account_xml))
''' % (header_xml,toxml(emp), '\n'.join(date_xml) + '\n'.join(account_xml))
return xml
report_custom('report.hr.analytical.timesheet', 'hr.employee', '', 'addons/hr_timesheet/report/user_timesheet.xsl')
+8 -19
View File
@@ -3,20 +3,14 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:call-template name="rml" />
</xsl:template>
<xsl:import href="custom_default.xsl"/>
<xsl:import href="custom_rml.xsl"/>
<xsl:template match="/">
<xsl:call-template name="rml"/>
</xsl:template>
<xsl:template name="rml">
<document filename="example.pdf">
<template pageSize="29.7cm,21cm" leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Timesheets" author="Generated by Open ERP, Fabien Pinckaers" allowSplitting="20">
<pageTemplate id="first">
<frame id="col1" x1="2.0cm" y1="2.5cm" width="24.7cm" height="17cm"/>
</pageTemplate>
</template>
<stylesheet>
<xsl:template name="stylesheet">
<paraStyle name="normal" fontName="Helvetica" fontSize="6" alignment="left" />
<paraStyle name="normal-title" fontName="Helvetica" fontSize="6" />
<paraStyle name="title" fontName="Helvetica" fontSize="18" alignment="center" />
@@ -50,15 +44,10 @@
<lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
<blockValign value="TOP"/>
</blockTableStyle>
</stylesheet>
<story>
<xsl:call-template name="story"/>
</story>
</document>
</xsl:template>
</xsl:template>
<xsl:template name="story">
<spacer length="1cm" />
<para style="title" t="1">Timesheet</para>
<spacer length="1cm" />
<para style="employee"><xsl:value-of select="/report/employee" /></para>
+11 -2
View File
@@ -22,7 +22,8 @@
import datetime
from report.interface import report_rml
from report.interface import toxml
import time
import pooler
from tools.translate import _
@@ -96,12 +97,20 @@ class report_custom(report_rml):
#Without this, report don't show non-ascii characters (TO CHECK)
date_xml = '\n'.join(date_xml)
header_xml = '''
<header>
<date>%s</date>
<company>%s</company>
</header>
''' % (time.strftime('%m/%d/%Y %H:%M'),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name)
xml='''<?xml version="1.0" encoding="UTF-8" ?>
<report>
%s
%s
%s
</report>
''' % (date_xml, emp_xml)
''' % (header_xml,date_xml, emp_xml)
return xml
report_custom('report.hr.analytical.timesheet_users', 'hr.employee', '', 'addons/hr_timesheet/report/users_timesheet.xsl')
+6 -16
View File
@@ -3,20 +3,15 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="custom_default.xsl"/>
<xsl:import href="custom_rml.xsl"/>
<xsl:template match="/">
<xsl:call-template name="rml" />
</xsl:template>
<xsl:template name="rml">
<document filename="example.pdf">
<template pageSize="29.7cm,21cm" leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Timesheets" author="Generated by Open ERP, Fabien Pinckaers" allowSplitting="20">
<pageTemplate id="first">
<frame id="col1" x1="2.0cm" y1="2.5cm" width="24.7cm" height="17cm"/>
</pageTemplate>
</template>
<stylesheet>
<xsl:template name="stylesheet">
<paraStyle name="normal" fontName="Helvetica" fontSize="6" alignment="center" />
<paraStyle name="normal-title" fontName="Helvetica" fontSize="6" />
<paraStyle name="title" fontName="Helvetica" fontSize="18" alignment="center" />
@@ -50,17 +45,12 @@
<lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
<blockValign value="TOP"/>
</blockTableStyle>
</stylesheet>
<story>
<xsl:call-template name="story"/>
</story>
</document>
</xsl:template>
<xsl:template name="story">
<para style="title" t="1">Employees Timesheet</para>
<spacer length="1cm" />
<para style="title" t="1">Employees Timesheet</para>
<spacer length="1.5cm" />
<blockTable>
<xsl:attribute name="style">month</xsl:attribute>
<xsl:attribute name="colWidths"><xsl:value-of select="report/cols" /></xsl:attribute>