Merge lp:~openerp-dev/openobject-addons/trunk-bug-798721-mtr into lp:openobject-addons

Proposed by Meera Trambadia (OpenERP)
Status: Merged
Merged at revision: 5225
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-798721-mtr
Merge into: lp:openobject-addons
Diff against target: 263 lines (+41/-31)
3 files modified
hr_attendance/report/attendance_by_month.py (+15/-13)
hr_attendance/report/bymonth.xsl (+10/-2)
hr_holidays/report/holidays_summary_report.py (+16/-16)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-798721-mtr
Reviewer Review Type Date Requested Status
Mustufa Rangwala (Open ERP) (community) Approve
Meera Trambadia (OpenERP) (community) Needs Resubmitting
qdp (OpenERP) Pending
Review via email: mp+66069@code.launchpad.net

Description of the change

hr_attendance, hr_holidays:monthly attendance and holidays summary report are now translated" --fixes=lp:798721

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

monthly attendance report => not fully translated still "Attendances By Month" (you have to make this string dynamic from py file only and remove it from xsl)
same for holidays report.

And yes you have to improve attendance by week report and other remaining reports too for translation.

Thanks,
mra

review: Needs Fixing
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have made the changes in 'Attendances by Month' report as per your suggestion.

For Employee Holidays report I have translated the month and weekdays string.

And for 'Weekly Attendance' and 'Employee Holidays' report it requires to transfer the strings from .xsl to .py(in the xml format) thus needs to redefine the report files.

So the patch here consist of the changes for 'Attendances by Month' and 'Employee Holidays'(partial changes) report.

review: Needs Resubmitting
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) :
review: Approve
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Translation no available for some strings in pot/po files so currently it does not translate.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_attendance/report/attendance_by_month.py'
--- hr_attendance/report/attendance_by_month.py 2011-02-07 09:36:21 +0000
+++ hr_attendance/report/attendance_by_month.py 2011-09-16 05:20:29 +0000
@@ -30,9 +30,10 @@
3030
31from report import report_sxw31from report import report_sxw
32from tools import ustr32from tools import ustr
33from tools.translate import _
3334
34one_day = relativedelta(days=1)35one_day = relativedelta(days=1)
35month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']36month2name = [0, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
3637
37def hour2str(h):38def hour2str(h):
38 hours = int(h)39 hours = int(h)
@@ -52,7 +53,7 @@
52 context = {}53 context = {}
53 month = datetime(datas['form']['year'], datas['form']['month'], 1)54 month = datetime(datas['form']['year'], datas['form']['month'], 1)
54 emp_ids = context.get('active_ids', [])55 emp_ids = context.get('active_ids', [])
55 user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]56 user_xml = ['<month>%s</month>' % _(month2name[month.month]), '<year>%s</year>' % month.year]
56 if emp_ids:57 if emp_ids:
57 for emp in obj_emp.read(cr, uid, emp_ids, ['name']):58 for emp in obj_emp.read(cr, uid, emp_ids, ['name']):
58 stop, days_xml = False, []59 stop, days_xml = False, []
@@ -95,7 +96,7 @@
95 days_xml.append(today_xml)96 days_xml.append(today_xml)
96 today, tomor = tomor, tomor + one_day97 today, tomor = tomor, tomor + one_day
97 user_xml.append(user_repr % '\n'.join(days_xml))98 user_xml.append(user_repr % '\n'.join(days_xml))
9899
99 rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')100 rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
100 rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)101 rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
101 header_xml = '''102 header_xml = '''
@@ -104,7 +105,7 @@
104 <company>%s</company>105 <company>%s</company>
105 </header>106 </header>
106 ''' % (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)107 ''' % (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)
107108
108 first_date = str(month)109 first_date = str(month)
109 som = datetime.strptime(first_date, '%Y-%m-%d %H:%M:%S')110 som = datetime.strptime(first_date, '%Y-%m-%d %H:%M:%S')
110 eom = som + timedelta(int(dy)-1)111 eom = som + timedelta(int(dy)-1)
@@ -113,12 +114,12 @@
113 cell=1114 cell=1
114 date_xml.append('<days>')115 date_xml.append('<days>')
115 if day_diff.days>=30:116 if day_diff.days>=30:
116 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)]117 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)]
117 else:118 else:
118 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):119 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
119 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)]120 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)]
120 else:121 else:
121 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)]122 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)]
122 cell=x-som.day+1123 cell=x-som.day+1
123 day_diff1=day_diff.days-cell+1124 day_diff1=day_diff.days-cell+1
124 width_dict={}125 width_dict={}
@@ -129,12 +130,12 @@
129 month=som.month130 month=som.month
130 month_dict[j]=som.strftime('%B')131 month_dict[j]=som.strftime('%B')
131 width_dict[j]=cell132 width_dict[j]=cell
132133
133 while day_diff1>0:134 while day_diff1>0:
134 if month+i<=12:135 if month+i<=12:
135 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example136 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
136 som1=datetime.date(year,month+i,1)137 som1=datetime.date(year,month+i,1)
137 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)]138 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)]
138 i=i+1139 i=i+1
139 j=j+1140 j=j+1
140 month_dict[j]=som1.strftime('%B')141 month_dict[j]=som1.strftime('%B')
@@ -142,7 +143,7 @@
142 width_dict[j]=x143 width_dict[j]=x
143 else:144 else:
144 som1=datetime.date(year,month+i,1)145 som1=datetime.date(year,month+i,1)
145 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)]146 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)]
146 i=i+1147 i=i+1
147 j=j+1148 j=j+1
148 month_dict[j]=som1.strftime('%B')149 month_dict[j]=som1.strftime('%B')
@@ -156,7 +157,7 @@
156 i=1157 i=1
157 if day_diff1>=30:158 if day_diff1>=30:
158 som1=datetime.date(years,i,1)159 som1=datetime.date(years,i,1)
159 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)]160 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)]
160 i=i+1161 i=i+1
161 j=j+1162 j=j+1
162 month_dict[j]=som1.strftime('%B')163 month_dict[j]=som1.strftime('%B')
@@ -167,7 +168,7 @@
167 i=i+1168 i=i+1
168 j=j+1169 j=j+1
169 month_dict[j]=som1.strftime('%B')170 month_dict[j]=som1.strftime('%B')
170 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)]171 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)]
171 cell=cell+x172 cell=cell+x
172 width_dict[j]=x173 width_dict[j]=x
173 day_diff1=day_diff1-x174 day_diff1=day_diff1-x
@@ -176,10 +177,11 @@
176 xml = '''<?xml version="1.0" encoding="UTF-8" ?>177 xml = '''<?xml version="1.0" encoding="UTF-8" ?>
177 <report>178 <report>
178 %s179 %s
180 <title>%s</title>
179 %s181 %s
180 %s182 %s
181 </report>183 </report>
182 ''' % (header_xml,'\n'.join(user_xml),date_xml)184 ''' % (header_xml,_('Attendances By Month'),'\n'.join(user_xml),date_xml)
183 return xml185 return xml
184186
185report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')187report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')
186188
=== modified file 'hr_attendance/report/bymonth.xsl'
--- hr_attendance/report/bymonth.xsl 2011-01-14 00:11:01 +0000
+++ hr_attendance/report/bymonth.xsl 2011-09-16 05:20:29 +0000
@@ -12,6 +12,7 @@
1212
1313
14 <xsl:template name="stylesheet">14 <xsl:template name="stylesheet">
15 <paraStyle name="title" fontName="Helvetica-Bold" fontSize="15.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
15 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>16 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
16 <paraStyle name="name" fontName="Helvetica" textColor="green" fontSize="7"/>17 <paraStyle name="name" fontName="Helvetica" textColor="green" fontSize="7"/>
17 <paraStyle name="normal" fontName="Helvetica" fontSize="6"/>18 <paraStyle name="normal" fontName="Helvetica" fontSize="6"/>
@@ -29,7 +30,7 @@
2930
30 <xsl:template name="story">31 <xsl:template name="story">
31 <spacer length="1cm" />32 <spacer length="1cm" />
32 <para style="terp_header_Centre" t="1">Attendances By Month</para>33 <xsl:apply-templates select="report/title"/>
33 <spacer length="1cm" />34 <spacer length="1cm" />
34 <blockTable>35 <blockTable>
35 <xsl:attribute name="style">week</xsl:attribute>36 <xsl:attribute name="style">week</xsl:attribute>
@@ -53,7 +54,14 @@
53 <xsl:apply-templates select="report/user"/>54 <xsl:apply-templates select="report/user"/>
54 </blockTable>55 </blockTable>
55 </xsl:template>56 </xsl:template>
5657
58 <xsl:template match="title">
59 <para style="title">
60 <xsl:value-of select="."/>
61 </para>
62 <spacer length="1cm"/>
63 </xsl:template>
64
57 <xsl:template match="user">65 <xsl:template match="user">
58<!-- <tr></tr>-->66<!-- <tr></tr>-->
59 <tr>67 <tr>
6068
=== modified file 'hr_holidays/report/holidays_summary_report.py'
--- hr_holidays/report/holidays_summary_report.py 2011-01-17 18:02:22 +0000
+++ hr_holidays/report/holidays_summary_report.py 2011-09-16 05:20:29 +0000
@@ -30,6 +30,7 @@
30import time30import time
31from report import report_sxw31from report import report_sxw
32from tools import ustr32from tools import ustr
33from tools.translate import _
3334
34def lengthmonth(year, month):35def lengthmonth(year, month):
35 if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):36 if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
@@ -69,9 +70,9 @@
69 for index in range(1,61):70 for index in range(1,61):
70 display[index]=' '71 display[index]=' '
71 count=''72 count=''
7273
73 data_xml=['<info id="%d" number="%d" val="%s" />' % (row_id,x,display[x]) for x in range(1,len(display)+1) ]74 data_xml=['<info id="%d" number="%d" val="%s" />' % (row_id,x,display[x]) for x in range(1,len(display)+1) ]
7475
75 # Computing the xml76 # Computing the xml
76 xml = '''77 xml = '''
77 %s78 %s
@@ -120,18 +121,17 @@
120121
121# date_xml=[]122# date_xml=[]
122 for l in range(0,len(legend)):123 for l in range(0,len(legend)):
123 date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],legend[l][1],legend[l][2])]124 date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],_(legend[l][1]),legend[l][2])]
124
125 date_xml += ['<date month="%s" year="%d" />' % (som.strftime('%B'), som.year),'<days>']125 date_xml += ['<date month="%s" year="%d" />' % (som.strftime('%B'), som.year),'<days>']
126126
127 cell=1127 cell=1
128 if day_diff.days>=30:128 if day_diff.days>=30:
129 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)]129 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)]
130 else:130 else:
131 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):131 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
132 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)]132 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)]
133 else:133 else:
134 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)]134 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)]
135135
136 cell=x-som.day+1136 cell=x-som.day+1
137 day_diff1=day_diff.days-cell+1137 day_diff1=day_diff.days-cell+1
@@ -150,7 +150,7 @@
150 if month+i<=12:150 if month+i<=12:
151 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example151 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
152 som1=datetime.date(year,month+i,1)152 som1=datetime.date(year,month+i,1)
153 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)]153 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)]
154 i=i+1154 i=i+1
155 j=j+1155 j=j+1
156 month_dict[j]=som1.strftime('%B')156 month_dict[j]=som1.strftime('%B')
@@ -159,7 +159,7 @@
159159
160 else:160 else:
161 som1=datetime.date(year,month+i,1)161 som1=datetime.date(year,month+i,1)
162 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)]162 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)]
163 i=i+1163 i=i+1
164 j=j+1164 j=j+1
165 month_dict[j]=som1.strftime('%B')165 month_dict[j]=som1.strftime('%B')
@@ -174,7 +174,7 @@
174 i=1174 i=1
175 if day_diff1>=30:175 if day_diff1>=30:
176 som1=datetime.date(years,i,1)176 som1=datetime.date(years,i,1)
177 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)]177 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)]
178 i=i+1178 i=i+1
179 j=j+1179 j=j+1
180 month_dict[j]=som1.strftime('%B')180 month_dict[j]=som1.strftime('%B')
@@ -186,7 +186,7 @@
186 i=i+1186 i=i+1
187 j=j+1187 j=j+1
188 month_dict[j]=som1.strftime('%B')188 month_dict[j]=som1.strftime('%B')
189 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)]189 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)]
190 cell=cell+x190 cell=cell+x
191 width_dict[j]=x191 width_dict[j]=x
192192
@@ -200,16 +200,16 @@
200 st+=',' + str(0.4 *width_dict[m])+'cm'200 st+=',' + str(0.4 *width_dict[m])+'cm'
201 st+=',0.4cm</cols_months>\n'201 st+=',0.4cm</cols_months>\n'
202202
203 months_xml =['<months number="%d" name="%s" />' % (x,month_dict[x]) for x in range(1,len(month_dict)+1) ]203 months_xml =['<months number="%d" name="%s"/>' % (x, _(month_dict[x])) for x in range(1,len(month_dict)+1) ]
204 months_xml.append(st)204 months_xml.append(st)
205205
206 emp_xml=''206 emp_xml=''
207 row_id=1207 row_id=1
208208
209 if data['model']=='hr.employee':209 if data['model']=='hr.employee':
210 for id in data['form']['emp']:210 for id in data['form']['emp']:
211 items = obj_emp.read(cr, uid, id, ['id','name'])211 items = obj_emp.read(cr, uid, id, ['id','name'])
212212
213 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, items['id'], items['name'], som, eom)213 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, items['id'], items['name'], som, eom)
214 row_id = row_id +1214 row_id = row_id +1
215215
@@ -229,7 +229,7 @@
229 dept_done=1229 dept_done=1
230 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)230 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)
231 row_id = row_id +1231 row_id = row_id +1
232232
233 header_xml = '''233 header_xml = '''
234 <header>234 <header>
235 <date>%s</date>235 <date>%s</date>

Subscribers

People subscribed via source and target branches

to all changes: