[REM] hr_timesheet: removed xsl/models of user(s) timesheet reports as they are not available since rev 9064 revid:ged@openerp.com-20140127161718-uo6pperke86pqq5v. They are already replaced by graphviews.
bzr revid: sle@openerp.com-20140425113228-obzblo2nmkmo2q58
This commit is contained in:
parent
5c69f3470d
commit
49fe785e64
|
@ -21,7 +21,6 @@
|
|||
|
||||
import hr_timesheet
|
||||
import wizard
|
||||
import report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ up a management by affair.
|
|||
'security/ir.model.access.csv',
|
||||
'security/hr_timesheet_security.xml',
|
||||
'hr_timesheet_view.xml',
|
||||
'hr_timesheet_report.xml',
|
||||
'hr_timesheet_wizard.xml',
|
||||
'process/hr_timesheet_process.xml',
|
||||
'wizard/hr_timesheet_sign_in_out_view.xml',
|
||||
'hr_timesheet_installer.xml',
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<report auto="False" id="report_user_timesheet" menu="False" model="hr.employee" name="hr.analytical.timesheet" string="Employee timesheet" xsl="hr_timesheet/report/user_timesheet.xsl"/>
|
||||
|
||||
<report auto="False" id="report_users_timesheet" menu="False" model="hr.employee" name="hr.analytical.timesheet_users" string="Employees Timesheet" xsl="hr_timesheet/report/users_timesheet.xsl"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,26 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import user_timesheet
|
||||
import users_timesheet
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,36 +0,0 @@
|
|||
<?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="DejaVuSans" size="8"/>
|
||||
<drawString x="1.3cm" y="19.5cm"><xsl:value-of select="//report/header/date"/></drawString>
|
||||
<setFont name="DejaVuSans-Bold" size="10"/>
|
||||
<drawString x="13.8cm" y="19.5cm"><xsl:value-of select="//report/header/company"/></drawString>
|
||||
<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="DejaVuSans" size="8"/>
|
||||
<drawString x="1.3cm" y="19.5cm"><xsl:value-of select="//report/header/date"/></drawString>
|
||||
<setFont name="DejaVuSans-Bold" size="10"/>
|
||||
<drawString x="27.8cm" y="19.5cm"><xsl:value-of select="//report/header/company"/></drawString>
|
||||
<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>
|
|
@ -1,37 +0,0 @@
|
|||
<?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>
|
|
@ -1,124 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import datetime
|
||||
import time
|
||||
|
||||
import openerp
|
||||
from openerp.report.interface import report_rml
|
||||
from openerp.report.interface import toxml
|
||||
from openerp.tools.translate import _
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools import ustr
|
||||
from openerp.tools import to_xml
|
||||
|
||||
def lengthmonth(year, month):
|
||||
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
|
||||
return 29
|
||||
return [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
||||
|
||||
class report_custom(report_rml):
|
||||
|
||||
def get_month_name(self, cr, uid, month, context=None):
|
||||
_months = {1:_("January"), 2:_("February"), 3:_("March"), 4:_("April"), 5:_("May"), 6:_("June"), 7:_("July"), 8:_("August"), 9:_("September"), 10:_("October"), 11:_("November"), 12:_("December")}
|
||||
return _months[month]
|
||||
def get_weekday_name(self, cr, uid, weekday, context=None):
|
||||
_weekdays = {1:_('Mon'), 2:_('Tue'), 3:_('Wed'), 4:_('Thu'), 5:_('Fri'), 6:_('Sat'), 7:_('Sun')}
|
||||
return _weekdays[weekday]
|
||||
|
||||
def create_xml(self, cr, uid, ids, data, context):
|
||||
registry = openerp.registry(cr.dbname)
|
||||
|
||||
# Get the user id from the selected employee record
|
||||
emp_id = data['form']['employee_id']
|
||||
emp_obj = registry['hr.employee']
|
||||
user_id = emp_obj.browse(cr, uid, emp_id).user_id.id
|
||||
empl_name = emp_obj.browse(cr, uid, emp_id).name
|
||||
|
||||
# Computing the dates (start of month: som, and end of month: eom)
|
||||
som = datetime.date(data['form']['year'], data['form']['month'], 1)
|
||||
eom = som + datetime.timedelta(lengthmonth(som.year, som.month))
|
||||
|
||||
date_xml = ['<date month="%s" year="%d" />' % (self.get_month_name(cr, uid, som.month, context=context), som.year), '<days>']
|
||||
date_xml += ['<day number="%d" name="%s" weekday="%d" />' % (x, self.get_weekday_name(cr, uid, som.replace(day=x).weekday()+1, context=context), som.replace(day=x).weekday()+1) for x in range(1, lengthmonth(som.year, som.month)+1)]
|
||||
|
||||
date_xml.append('</days>')
|
||||
date_xml.append('<cols>2.5cm%s,2cm</cols>\n' % (',0.7cm' * lengthmonth(som.year, som.month)))
|
||||
|
||||
# Sum attendence by account, then by day
|
||||
accounts = {}
|
||||
header_xml = ''
|
||||
if user_id:
|
||||
# Computing the attendence by analytical account
|
||||
cr.execute(
|
||||
"select line.date, (unit_amount / unit.factor) as amount, account_id, account.name "\
|
||||
"from account_analytic_line as line, hr_analytic_timesheet as hr, "\
|
||||
"account_analytic_account as account, product_uom as unit "\
|
||||
"where hr.line_id=line.id and line.account_id=account.id "\
|
||||
"and product_uom_id = unit.id "\
|
||||
"and line.user_id=%s and line.date >= %s and line.date < %s "
|
||||
"order by line.date",
|
||||
(user_id, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
|
||||
|
||||
for presence in cr.dictfetchall():
|
||||
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>
|
||||
'''
|
||||
rpt_obj = registry['hr.employee']
|
||||
rml_obj = report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
|
||||
if user_id:
|
||||
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")),to_xml(registry['res.users'].browse(cr,uid,user_id).company_id.name))
|
||||
|
||||
account_xml = []
|
||||
for account, telems in accounts.iteritems():
|
||||
aid, aname = account
|
||||
aname = registry['account.analytic.account'].name_get(cr, uid, [aid], context)
|
||||
aname = aname[0][1]
|
||||
|
||||
account_xml.append('<account id="%d" name="%s">' % (aid, toxml(aname)))
|
||||
account_xml.append('\n'.join([xml % (day, amount) for day, amount in telems.iteritems()]))
|
||||
account_xml.append('</account>')
|
||||
|
||||
# Computing the xml
|
||||
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report>
|
||||
%s
|
||||
<employee>%s</employee>
|
||||
%s
|
||||
</report>
|
||||
''' % (header_xml, ustr(toxml(empl_name)), '\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')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,123 +0,0 @@
|
|||
<?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:import href="custom_default.xsl"/>
|
||||
<xsl:import href="custom_rml.xsl"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="rml"/>
|
||||
</xsl:template>
|
||||
|
||||
<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" />
|
||||
<paraStyle name="employee" fontName="Helvetica-Oblique" fontSize="10" textColor="blue" />
|
||||
<paraStyle name="glande" textColor="red" fontSize="7" fontName="Helvetica"/>
|
||||
<paraStyle name="normal_people" textColor="green" fontSize="7" fontName="Helvetica"/>
|
||||
<paraStyle name="esclave" textColor="purple" fontSize="7" fontName="Helvetica"/>
|
||||
<blockTableStyle id="month">
|
||||
<blockAlignment value="CENTER" start="1,0" stop="-1,-1" />
|
||||
<blockFont name="Helvetica" size="8" start="0,0" stop="-1,1"/>
|
||||
<blockFont name="Helvetica" size="6" start="0,2" stop="-2,-2"/>
|
||||
<blockFont name="Helvetica-BoldOblique" size="8" start="0,-1" stop="-1,-1"/>
|
||||
<blockBackground colorName="#AAAAAA" start="1,0" stop="-2,1"/>
|
||||
<xsl:for-each select="/report/days/day[@weekday=6 or @weekday=7]">
|
||||
<xsl:variable name="col" select="attribute::number" />
|
||||
<blockBackground>
|
||||
<xsl:attribute name="colorName">lightgrey</xsl:attribute>
|
||||
<xsl:attribute name="start">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,0</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="stop">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,-1</xsl:text>
|
||||
</xsl:attribute>
|
||||
</blockBackground>
|
||||
</xsl:for-each>
|
||||
<lineStyle kind="LINEABOVE" colorName="black" start="0,0" stop="-1,-1" />
|
||||
<lineStyle kind="LINEBEFORE" colorName="black" start="0,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEAFTER" colorName="black" start="-1,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="story">
|
||||
<spacer length="1cm" />
|
||||
<para style="title" t="1">Timesheet by Employee</para>
|
||||
<spacer length="1cm" />
|
||||
<para style="employee"><xsl:value-of select="/report/employee" /></para>
|
||||
<spacer length="1cm" />
|
||||
<blockTable>
|
||||
<xsl:attribute name="style">month</xsl:attribute>
|
||||
<xsl:attribute name="colWidths"><xsl:value-of select="report/cols" /></xsl:attribute>
|
||||
<tr>
|
||||
<td><xsl:value-of select="report/date/attribute::year" /></td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<td>
|
||||
<xsl:value-of select="attribute::name" />
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><xsl:value-of select="report/date/attribute::month" /></td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<td>
|
||||
<xsl:value-of select="attribute::number" />
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td t="1">Total</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="report/account"/>
|
||||
<tr>
|
||||
<td t="1">Sum</td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<xsl:variable name="today" select="attribute::number" />
|
||||
<td>
|
||||
<para style="normal">
|
||||
<xsl:choose>
|
||||
<xsl:when test="sum(//time-element[@date=$today]) < 7.5">
|
||||
<xsl:attribute name="style">glande</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="sum(//time-element[@date=$today]) < 8.5 and sum(//time-element[@date=$today]) >= 7.5">
|
||||
<xsl:attribute name="style">normal_people</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="style">esclave</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="format-number(sum(//time-element[@date=$today]),'##.##')" />
|
||||
</para>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td>
|
||||
<xsl:value-of select="format-number(sum(//time-element),'##.##')" />
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="account">
|
||||
<xsl:variable name="aid" select="attribute::id" />
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<para style="normal-title"><xsl:value-of select="attribute::name" /></para>
|
||||
</td>
|
||||
<xsl:for-each select="/report/days/day">
|
||||
<xsl:variable name="today" select="attribute::number" />
|
||||
<td>
|
||||
<para style="normal"><xsl:value-of select="//account[@id=$aid]/time-element[@date=$today]" /></para>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td>
|
||||
<para style="normal"><xsl:value-of select="format-number(sum(//account[@id=$aid]/time-element),'##.##')" /></para>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
|
@ -1,123 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import datetime
|
||||
import time
|
||||
|
||||
import openerp
|
||||
from openerp.report.interface import report_rml
|
||||
from openerp.report.interface import toxml
|
||||
from openerp.tools.translate import _
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools import ustr
|
||||
|
||||
|
||||
def lengthmonth(year, month):
|
||||
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
|
||||
return 29
|
||||
return [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
||||
|
||||
def emp_create_xml(cr, id, som, eom, emp):
|
||||
# Computing the attendence by analytical account
|
||||
cr.execute(
|
||||
"select line.date, (unit_amount / unit.factor) as amount "\
|
||||
"from account_analytic_line as line, hr_analytic_timesheet as hr, "\
|
||||
"product_uom as unit "\
|
||||
"where hr.line_id=line.id "\
|
||||
"and product_uom_id = unit.id "\
|
||||
"and line.user_id=%s and line.date >= %s and line.date < %s "
|
||||
"order by line.date",
|
||||
(id, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
|
||||
|
||||
# Sum by day
|
||||
month = {}
|
||||
for presence in cr.dictfetchall():
|
||||
day = int(presence['date'][-2:])
|
||||
month[day] = month.get(day, 0.0) + presence['amount']
|
||||
|
||||
xml = '''
|
||||
<time-element date="%s">
|
||||
<amount>%.2f</amount>
|
||||
</time-element>
|
||||
'''
|
||||
time_xml = ([xml % (day, amount) for day, amount in month.iteritems()])
|
||||
|
||||
# Computing the xml
|
||||
xml = '''
|
||||
<employee id="%d" name="%s">
|
||||
%s
|
||||
</employee>
|
||||
''' % (id, toxml(emp), '\n'.join(time_xml))
|
||||
return xml
|
||||
|
||||
class report_custom(report_rml):
|
||||
|
||||
def get_month_name(self, cr, uid, month, context=None):
|
||||
_months = {1:_("January"), 2:_("February"), 3:_("March"), 4:_("April"), 5:_("May"), 6:_("June"), 7:_("July"), 8:_("August"), 9:_("September"), 10:_("October"), 11:_("November"), 12:_("December")}
|
||||
return _months[month]
|
||||
|
||||
def get_weekday_name(self, cr, uid, weekday, context=None):
|
||||
_weekdays = {1:_('Mon'), 2:_('Tue'), 3:_('Wed'), 4:_('Thu'), 5:_('Fri'), 6:_('Sat'), 7:_('Sun')}
|
||||
return _weekdays[weekday]
|
||||
|
||||
def create_xml(self, cr, uid, ids, data, context):
|
||||
registry = openerp.registry(cr.dbname)
|
||||
|
||||
# Computing the dates (start of month: som, and end of month: eom)
|
||||
som = datetime.date(data['form']['year'], data['form']['month'], 1)
|
||||
eom = som + datetime.timedelta(lengthmonth(som.year, som.month))
|
||||
date_xml = ['<date month="%s" year="%d" />' % (self.get_month_name(cr, uid, som.month, context=context), som.year), '<days>']
|
||||
date_xml += ['<day number="%d" name="%s" weekday="%d" />' % (x, self.get_weekday_name(cr, uid, som.replace(day=x).weekday()+1, context=context), som.replace(day=x).weekday()+1) for x in range(1, lengthmonth(som.year, som.month)+1)]
|
||||
date_xml.append('</days>')
|
||||
date_xml.append('<cols>2.5cm%s,2cm</cols>\n' % (',0.7cm' * lengthmonth(som.year, som.month)))
|
||||
|
||||
emp_xml=''
|
||||
emp_obj = registry['hr.employee']
|
||||
for id in data['form']['employee_ids']:
|
||||
user = emp_obj.browse(cr, uid, id).user_id.id
|
||||
empl_name = emp_obj.browse(cr, uid, id).name
|
||||
if user:
|
||||
emp_xml += emp_create_xml(cr, user, som, eom, empl_name)
|
||||
# Computing the xml
|
||||
#Without this, report don't show non-ascii characters (TO CHECK)
|
||||
date_xml = '\n'.join(date_xml)
|
||||
rpt_obj = emp_obj
|
||||
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")),toxml(registry['res.users'].browse(cr,uid,uid).company_id.name))
|
||||
|
||||
xml='''<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report>
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
</report>
|
||||
''' % (header_xml,date_xml, ustr(emp_xml))
|
||||
return xml
|
||||
|
||||
report_custom('report.hr.analytical.timesheet_users', 'hr.employee', '', 'addons/hr_timesheet/report/users_timesheet.xsl')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
<?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:import href="custom_default.xsl"/>
|
||||
<xsl:import href="custom_rml.xsl"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="rml" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<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" />
|
||||
<paraStyle name="employee" fontName="Helvetica-Oblique" fontSize="10" textColor="blue" />
|
||||
<paraStyle name="glande" textColor="red" fontSize="7" fontName="Helvetica"/>
|
||||
<paraStyle name="normal_people" textColor="green" fontSize="7" fontName="Helvetica"/>
|
||||
<paraStyle name="esclave" textColor="purple" fontSize="7" fontName="Helvetica"/>
|
||||
<blockTableStyle id="month">
|
||||
<blockAlignment value="CENTER" start="1,0" stop="-1,-1" />
|
||||
<blockFont name="Helvetica" size="8" start="0,0" stop="-1,1"/>
|
||||
<blockFont name="Helvetica" size="6" start="0,2" stop="-2,-2"/>
|
||||
<blockFont name="Helvetica-BoldOblique" size="8" start="0,-1" stop="-1,-1"/>
|
||||
<blockBackground colorName="#AAAAAA" start="1,0" stop="-2,1"/>
|
||||
<xsl:for-each select="/report/days/day[@weekday=6 or @weekday=7]">
|
||||
<xsl:variable name="col" select="attribute::number" />
|
||||
<blockBackground>
|
||||
<xsl:attribute name="colorName">lightgrey</xsl:attribute>
|
||||
<xsl:attribute name="start">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,0</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="stop">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,-1</xsl:text>
|
||||
</xsl:attribute>
|
||||
</blockBackground>
|
||||
</xsl:for-each>
|
||||
<lineStyle kind="LINEABOVE" colorName="black" start="0,0" stop="-1,-1" />
|
||||
<lineStyle kind="LINEBEFORE" colorName="black" start="0,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEAFTER" colorName="black" start="-1,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="story">
|
||||
<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>
|
||||
<tr>
|
||||
<td><xsl:value-of select="report/date/attribute::year" /></td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<td>
|
||||
<xsl:value-of select="attribute::name" />
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><xsl:value-of select="report/date/attribute::month" /></td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<td>
|
||||
<xsl:value-of select="attribute::number" />
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td t="1">Total</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="report/employee"/>
|
||||
<xsl:for-each select="report/employee">
|
||||
<xsl:variable name="id" select="attribute::id"/>
|
||||
<tr>
|
||||
<td><xsl:value-of select="attribute::name"/></td>
|
||||
<xsl:for-each select="//report/days/day">
|
||||
<xsl:variable name="today" select="attribute::number" />
|
||||
<td>
|
||||
<para>
|
||||
<xsl:choose>
|
||||
<xsl:when test="sum(//employee[@id=$id]/time-element[@date=$today]) < 7.5">
|
||||
<xsl:attribute name="style">glande</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="sum(//employee[@id=$id]/time-element[@date=$today]) < 8.5 and sum(//time-element[@date=$today]) >= 7.5">
|
||||
<xsl:attribute name="style">normal_people</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="style">esclave</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="format-number(sum(//employee[@id=$id]/time-element[@date=$today]), '##.##')" />
|
||||
</para>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td>
|
||||
<xsl:value-of select="format-number(sum(//employee[@id=$id]/time-element),'##.##')"/>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
<tr>
|
||||
<td t="1">Total</td>
|
||||
<xsl:for-each select="report/days/day">
|
||||
<xsl:variable name="today" select="attribute::number"/>
|
||||
<td><xsl:value-of select="format-number(sum(//time-element[@date=$today]),'##.##')"/></td>
|
||||
</xsl:for-each>
|
||||
<td><xsl:value-of select="format-number(sum(//time-element),'##.##')"/></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue