commit
9a158a41eb
|
@ -30,9 +30,10 @@ from report.interface import toxml
|
|||
|
||||
from report import report_sxw
|
||||
from tools import ustr
|
||||
from tools.translate import _
|
||||
|
||||
one_day = relativedelta(days=1)
|
||||
month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
month2name = [0, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
def hour2str(h):
|
||||
hours = int(h)
|
||||
|
@ -52,7 +53,7 @@ class report_custom(report_rml):
|
|||
context = {}
|
||||
month = datetime(datas['form']['year'], datas['form']['month'], 1)
|
||||
emp_ids = context.get('active_ids', [])
|
||||
user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]
|
||||
user_xml = ['<month>%s</month>' % _(month2name[month.month]), '<year>%s</year>' % month.year]
|
||||
if emp_ids:
|
||||
for emp in obj_emp.read(cr, uid, emp_ids, ['name']):
|
||||
stop, days_xml = False, []
|
||||
|
@ -113,12 +114,12 @@ class report_custom(report_rml):
|
|||
cell=1
|
||||
date_xml.append('<days>')
|
||||
if day_diff.days>=30:
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
else:
|
||||
if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
else:
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, eom.day+1)]
|
||||
cell=x-som.day+1
|
||||
day_diff1=day_diff.days-cell+1
|
||||
width_dict={}
|
||||
|
@ -134,7 +135,7 @@ class report_custom(report_rml):
|
|||
if month+i<=12:
|
||||
if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
|
||||
som1=datetime.date(year,month+i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -142,7 +143,7 @@ class report_custom(report_rml):
|
|||
width_dict[j]=x
|
||||
else:
|
||||
som1=datetime.date(year,month+i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -156,7 +157,7 @@ class report_custom(report_rml):
|
|||
i=1
|
||||
if day_diff1>=30:
|
||||
som1=datetime.date(years,i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(years,i)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(years,i)+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -167,7 +168,7 @@ class report_custom(report_rml):
|
|||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
|
||||
cell=cell+x
|
||||
width_dict[j]=x
|
||||
day_diff1=day_diff1-x
|
||||
|
@ -176,10 +177,11 @@ class report_custom(report_rml):
|
|||
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report>
|
||||
%s
|
||||
<title>%s</title>
|
||||
%s
|
||||
%s
|
||||
</report>
|
||||
''' % (header_xml,'\n'.join(user_xml),date_xml)
|
||||
''' % (header_xml,_('Attendances By Month'),'\n'.join(user_xml),date_xml)
|
||||
return xml
|
||||
|
||||
report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
|
||||
<xsl:template name="stylesheet">
|
||||
<paraStyle name="title" fontName="Helvetica-Bold" fontSize="15.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<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"/>
|
||||
|
@ -29,7 +30,7 @@
|
|||
|
||||
<xsl:template name="story">
|
||||
<spacer length="1cm" />
|
||||
<para style="terp_header_Centre" t="1">Attendances By Month</para>
|
||||
<xsl:apply-templates select="report/title"/>
|
||||
<spacer length="1cm" />
|
||||
<blockTable>
|
||||
<xsl:attribute name="style">week</xsl:attribute>
|
||||
|
@ -54,6 +55,13 @@
|
|||
</blockTable>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="title">
|
||||
<para style="title">
|
||||
<xsl:value-of select="."/>
|
||||
</para>
|
||||
<spacer length="1cm"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="user">
|
||||
<!-- <tr></tr>-->
|
||||
<tr>
|
||||
|
|
|
@ -30,6 +30,7 @@ import pooler
|
|||
import time
|
||||
from report import report_sxw
|
||||
from tools import ustr
|
||||
from tools.translate import _
|
||||
|
||||
def lengthmonth(year, month):
|
||||
if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
|
||||
|
@ -120,18 +121,17 @@ class report_custom(report_rml):
|
|||
|
||||
# date_xml=[]
|
||||
for l in range(0,len(legend)):
|
||||
date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],legend[l][1],legend[l][2])]
|
||||
|
||||
date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],_(legend[l][1]),legend[l][2])]
|
||||
date_xml += ['<date month="%s" year="%d" />' % (som.strftime('%B'), som.year),'<days>']
|
||||
|
||||
cell=1
|
||||
if day_diff.days>=30:
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
else:
|
||||
if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
|
||||
else:
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som.replace(day=x).strftime('%a'),x-som.day+1) for x in range(som.day, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, eom.day+1)]
|
||||
|
||||
cell=x-som.day+1
|
||||
day_diff1=day_diff.days-cell+1
|
||||
|
@ -150,7 +150,7 @@ class report_custom(report_rml):
|
|||
if month+i<=12:
|
||||
if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
|
||||
som1=datetime.date(year,month+i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -159,7 +159,7 @@ class report_custom(report_rml):
|
|||
|
||||
else:
|
||||
som1=datetime.date(year,month+i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -174,7 +174,7 @@ class report_custom(report_rml):
|
|||
i=1
|
||||
if day_diff1>=30:
|
||||
som1=datetime.date(years,i,1)
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(years,i)+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(years,i)+1)]
|
||||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
|
@ -186,7 +186,7 @@ class report_custom(report_rml):
|
|||
i=i+1
|
||||
j=j+1
|
||||
month_dict[j]=som1.strftime('%B')
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, eom.day+1)]
|
||||
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
|
||||
cell=cell+x
|
||||
width_dict[j]=x
|
||||
|
||||
|
@ -200,7 +200,7 @@ class report_custom(report_rml):
|
|||
st+=',' + str(0.4 *width_dict[m])+'cm'
|
||||
st+=',0.4cm</cols_months>\n'
|
||||
|
||||
months_xml =['<months number="%d" name="%s" />' % (x,month_dict[x]) for x in range(1,len(month_dict)+1) ]
|
||||
months_xml =['<months number="%d" name="%s"/>' % (x, _(month_dict[x])) for x in range(1,len(month_dict)+1) ]
|
||||
months_xml.append(st)
|
||||
|
||||
emp_xml=''
|
||||
|
|
Loading…
Reference in New Issue