[IMP]:hr_attandance:improved Attendance By Month.

bzr revid: apa@tinyerp.com-20100827130234-cmht1cqe4djexsjn
This commit is contained in:
saz(OpenERP)
2010-08-27 18:32:34 +05:30
committed by apa-tiny
parent b8771e21a9
commit 3a8b4898c4
2 changed files with 22 additions and 16 deletions
@@ -32,10 +32,10 @@ from report.interface import toxml
one_day = DateTime.RelativeDateTime(days=1)
month2name = [0, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
def hour2str(h):
hours = int(h)
minutes = int(round((h - hours) * 60, 0))
return '%02dh%02d' % (hours, minutes)
#def hour2str(h):
# hours = int(h)
# minutes = int(round((h - hours) * 60, 0))
# return '%02dh%02d' % (hours, minutes)
class report_custom(report_rml):
@@ -67,7 +67,7 @@ class report_custom(report_rml):
'''
cr.execute(sql, (today.strftime('%Y-%m-%d %H:%M:%S'), tomor.strftime('%Y-%m-%d %H:%M:%S'), emp['id']))
attendences = cr.dictfetchall()
wh = 0
wh = 0.0
# Fake sign ins/outs at week ends, to take attendances across week ends into account
if attendences and attendences[0]['action'] == 'sign_out':
attendences.insert(0, {'name': today.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_in'})
@@ -80,8 +80,8 @@ class report_custom(report_rml):
wh += (dt - ldt).hours
ldt = dt
# Week xml representation
wh = hour2str(wh)
today_xml = '<day num="%s"><wh>%s</wh></day>' % ((today - month).days+1, wh)
# wh = hour2str(wh)
today_xml = '<day num="%s"><wh>%s</wh></day>' % ((today - month).days+1, round(wh,2))
days_xml.append(today_xml)
today, tomor = tomor, tomor + one_day
user_xml.append(user_repr % '\n'.join(days_xml))
@@ -94,4 +94,4 @@ class report_custom(report_rml):
report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+14 -8
View File
@@ -10,7 +10,7 @@
<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">
<template pageSize="29.7cm,21cm" leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Attendance By Month" author="Generated by Open ERP, Fabien Pinckaers" allowSplitting="20">
<pageTemplate id="first">
<pageGraphics>
<drawRightString x="19.0cm" y="26.0cm"><xsl:value-of select="date"/></drawRightString>
@@ -18,8 +18,9 @@
<frame id="col1" x1="2.0cm" y1="2.5cm" width="22.7cm" height="18cm"/>
</pageTemplate>
</template>
<stylesheet>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="name" fontName="Helvetica" textColor="green" fontSize="7"/>
<paraStyle name="normal" fontName="Helvetica" fontSize="6"/>
<blockTableStyle id="week">
@@ -29,6 +30,7 @@
<lineStyle kind="LINEABOVE" colorName="grey" start="0,0" stop="-1,0" />
<lineStyle kind="LINEBEFORE" colorName="grey" start="0,0" stop="-1,-1"/>
<lineStyle kind="LINEAFTER" colorName="grey" start="-1,0" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="grey" start="0,0" stop="-1,-1"/>
<blockValign value="TOP"/>
</blockTableStyle>
</stylesheet>
@@ -40,8 +42,10 @@
</xsl:template>
<xsl:template name="story">
<para style="terp_header_Centre" t="1">Attendance By Month</para>
<spacer length="1cm" />
<blockTable
colWidths="2cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm,0.79cm" style="week">
colWidths="3cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm,0.69cm" style="week">
<tr>
<td><xsl:value-of select="/report/month" /><xsl:text> </xsl:text><xsl:value-of select="/report/year" /></td>
<td>1</td>
@@ -77,21 +81,23 @@
<td>31</td>
</tr>
<xsl:apply-templates select="report/user"/>
</blockTable>
</blockTable>
</xsl:template>
<xsl:template match="user">
<tr></tr>
<!-- <tr></tr>-->
<tr>
<td>
<para style="name"><xsl:value-of select="name" /></para>
</td>
</tr>
<tr>
<td>Worked</td>
<xsl:for-each select="day">
<td><xsl:value-of select="wh" /></td>
</xsl:for-each>
</tr>
<!-- <tr>-->
<!-- <td>Worked</td>-->
<!-- -->
<!-- </tr>-->
</xsl:template>
</xsl:stylesheet>