[IMP] hr_attendance: made report visible & added header in 'Attendance by Week' report
bzr revid: cha@tinyerp.com-20121016072635-aqx7jmysakwkg7fz
This commit is contained in:
parent
010b1ce69b
commit
bac6c2151f
|
@ -20,12 +20,15 @@
|
|||
##############################################################################
|
||||
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
import pooler
|
||||
from report.interface import report_rml
|
||||
from report.interface import toxml
|
||||
from report import report_sxw
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
one_week = relativedelta(days=7)
|
||||
|
@ -39,6 +42,7 @@ class report_custom(report_rml):
|
|||
def create_xml(self, cr, uid, ids, datas, context=None):
|
||||
obj_emp = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
|
||||
emp_ids = datas['active_ids']
|
||||
start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d')
|
||||
end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d')
|
||||
first_monday = start_date - relativedelta(days=start_date.date().weekday())
|
||||
|
@ -47,9 +51,16 @@ class report_custom(report_rml):
|
|||
if last_monday < first_monday:
|
||||
first_monday, last_monday = last_monday, first_monday
|
||||
|
||||
rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
|
||||
header_xml = '''
|
||||
<header>
|
||||
<date>%s</date>
|
||||
<company>%s</company>
|
||||
</header>
|
||||
''' % (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)
|
||||
user_xml = []
|
||||
|
||||
for employee_id in ids:
|
||||
for employee_id in emp_ids:
|
||||
emp = obj_emp.read(cr, uid, [employee_id], ['id', 'name'])[0]
|
||||
monday, n_monday = first_monday, first_monday + one_week
|
||||
stop, week_xml = False, []
|
||||
|
@ -103,12 +114,13 @@ class report_custom(report_rml):
|
|||
|
||||
monday, n_monday = n_monday, n_monday + one_week
|
||||
user_xml.append(user_repr % '\n'.join(week_xml))
|
||||
|
||||
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report>
|
||||
%s
|
||||
<title>%s</title>
|
||||
%s
|
||||
</report>
|
||||
''' % '\n'.join(user_xml)
|
||||
''' % (header_xml,_('Attendances By Week'),'\n'.join(user_xml))
|
||||
xml = tools.ustr(xml).encode('utf8')
|
||||
return self.post_process_xml_data(cr, uid, xml, context)
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
||||
|
||||
<xsl:import href="hr_custom_default.xsl"/>
|
||||
<xsl:import href="hr_custom_rml.xsl"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="rml" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="rml">
|
||||
<xsl:template name="stylesheet">
|
||||
<document filename="timesheet.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">
|
||||
|
@ -20,6 +23,7 @@
|
|||
</template>
|
||||
|
||||
<stylesheet>
|
||||
<paraStyle name="title" fontName="Helvetica-Bold" fontSize="15.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<blockTableStyle id="week">
|
||||
<blockFont name="Helvetica-BoldOblique" size="12" start="0,0" stop="-1,0"/>
|
||||
<blockBackground colorName="grey" start="0,0" stop="-1,0"/>
|
||||
|
@ -36,9 +40,19 @@
|
|||
</xsl:template>
|
||||
|
||||
<xsl:template name="story">
|
||||
<spacer length="1cm" />
|
||||
<xsl:apply-templates select="report/title"/>
|
||||
<spacer length="1cm" />
|
||||
<xsl:apply-templates select="report/user"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="title">
|
||||
<para style="title">
|
||||
<xsl:value-of select="."/>
|
||||
</para>
|
||||
<spacer length="1cm"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="user">
|
||||
<para>
|
||||
<b>Name:</b>
|
||||
|
|
|
@ -37,6 +37,7 @@ class hr_attendance_byweek(osv.osv_memory):
|
|||
def print_report(self, cr, uid, ids, context=None):
|
||||
datas = {
|
||||
'ids': [],
|
||||
'active_ids': context['active_ids'],
|
||||
'model': 'hr.employee',
|
||||
'form': self.read(cr, uid, ids)[0]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue