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
1=== modified file 'hr_attendance/report/attendance_by_month.py'
2--- hr_attendance/report/attendance_by_month.py 2011-02-07 09:36:21 +0000
3+++ hr_attendance/report/attendance_by_month.py 2011-09-16 05:20:29 +0000
4@@ -30,9 +30,10 @@
5
6 from report import report_sxw
7 from tools import ustr
8+from tools.translate import _
9
10 one_day = relativedelta(days=1)
11-month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']
12+month2name = [0, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
13
14 def hour2str(h):
15 hours = int(h)
16@@ -52,7 +53,7 @@
17 context = {}
18 month = datetime(datas['form']['year'], datas['form']['month'], 1)
19 emp_ids = context.get('active_ids', [])
20- user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]
21+ user_xml = ['<month>%s</month>' % _(month2name[month.month]), '<year>%s</year>' % month.year]
22 if emp_ids:
23 for emp in obj_emp.read(cr, uid, emp_ids, ['name']):
24 stop, days_xml = False, []
25@@ -95,7 +96,7 @@
26 days_xml.append(today_xml)
27 today, tomor = tomor, tomor + one_day
28 user_xml.append(user_repr % '\n'.join(days_xml))
29-
30+
31 rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
32 rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
33 header_xml = '''
34@@ -104,7 +105,7 @@
35 <company>%s</company>
36 </header>
37 ''' % (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)
38-
39+
40 first_date = str(month)
41 som = datetime.strptime(first_date, '%Y-%m-%d %H:%M:%S')
42 eom = som + timedelta(int(dy)-1)
43@@ -113,12 +114,12 @@
44 cell=1
45 date_xml.append('<days>')
46 if day_diff.days>=30:
47- 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)]
48+ 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)]
49 else:
50 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
51- 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)]
52+ 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)]
53 else:
54- 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)]
55+ 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)]
56 cell=x-som.day+1
57 day_diff1=day_diff.days-cell+1
58 width_dict={}
59@@ -129,12 +130,12 @@
60 month=som.month
61 month_dict[j]=som.strftime('%B')
62 width_dict[j]=cell
63-
64+
65 while day_diff1>0:
66 if month+i<=12:
67 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
68 som1=datetime.date(year,month+i,1)
69- 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)]
70+ 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)]
71 i=i+1
72 j=j+1
73 month_dict[j]=som1.strftime('%B')
74@@ -142,7 +143,7 @@
75 width_dict[j]=x
76 else:
77 som1=datetime.date(year,month+i,1)
78- 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)]
79+ 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)]
80 i=i+1
81 j=j+1
82 month_dict[j]=som1.strftime('%B')
83@@ -156,7 +157,7 @@
84 i=1
85 if day_diff1>=30:
86 som1=datetime.date(years,i,1)
87- 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)]
88+ 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)]
89 i=i+1
90 j=j+1
91 month_dict[j]=som1.strftime('%B')
92@@ -167,7 +168,7 @@
93 i=i+1
94 j=j+1
95 month_dict[j]=som1.strftime('%B')
96- 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)]
97+ 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)]
98 cell=cell+x
99 width_dict[j]=x
100 day_diff1=day_diff1-x
101@@ -176,10 +177,11 @@
102 xml = '''<?xml version="1.0" encoding="UTF-8" ?>
103 <report>
104 %s
105+ <title>%s</title>
106 %s
107 %s
108 </report>
109- ''' % (header_xml,'\n'.join(user_xml),date_xml)
110+ ''' % (header_xml,_('Attendances By Month'),'\n'.join(user_xml),date_xml)
111 return xml
112
113 report_custom('report.hr.attendance.bymonth', 'hr.employee', '', 'addons/hr_attendance/report/bymonth.xsl')
114
115=== modified file 'hr_attendance/report/bymonth.xsl'
116--- hr_attendance/report/bymonth.xsl 2011-01-14 00:11:01 +0000
117+++ hr_attendance/report/bymonth.xsl 2011-09-16 05:20:29 +0000
118@@ -12,6 +12,7 @@
119
120
121 <xsl:template name="stylesheet">
122+ <paraStyle name="title" fontName="Helvetica-Bold" fontSize="15.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
123 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
124 <paraStyle name="name" fontName="Helvetica" textColor="green" fontSize="7"/>
125 <paraStyle name="normal" fontName="Helvetica" fontSize="6"/>
126@@ -29,7 +30,7 @@
127
128 <xsl:template name="story">
129 <spacer length="1cm" />
130- <para style="terp_header_Centre" t="1">Attendances By Month</para>
131+ <xsl:apply-templates select="report/title"/>
132 <spacer length="1cm" />
133 <blockTable>
134 <xsl:attribute name="style">week</xsl:attribute>
135@@ -53,7 +54,14 @@
136 <xsl:apply-templates select="report/user"/>
137 </blockTable>
138 </xsl:template>
139-
140+
141+ <xsl:template match="title">
142+ <para style="title">
143+ <xsl:value-of select="."/>
144+ </para>
145+ <spacer length="1cm"/>
146+ </xsl:template>
147+
148 <xsl:template match="user">
149 <!-- <tr></tr>-->
150 <tr>
151
152=== modified file 'hr_holidays/report/holidays_summary_report.py'
153--- hr_holidays/report/holidays_summary_report.py 2011-01-17 18:02:22 +0000
154+++ hr_holidays/report/holidays_summary_report.py 2011-09-16 05:20:29 +0000
155@@ -30,6 +30,7 @@
156 import time
157 from report import report_sxw
158 from tools import ustr
159+from tools.translate import _
160
161 def lengthmonth(year, month):
162 if month == 2 and ((year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))):
163@@ -69,9 +70,9 @@
164 for index in range(1,61):
165 display[index]=' '
166 count=''
167-
168+
169 data_xml=['<info id="%d" number="%d" val="%s" />' % (row_id,x,display[x]) for x in range(1,len(display)+1) ]
170-
171+
172 # Computing the xml
173 xml = '''
174 %s
175@@ -120,18 +121,17 @@
176
177 # date_xml=[]
178 for l in range(0,len(legend)):
179- date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],legend[l][1],legend[l][2])]
180-
181+ date_xml += ['<legend row="%d" id="%d" name="%s" color="%s" />' % (l+1,legend[l][0],_(legend[l][1]),legend[l][2])]
182 date_xml += ['<date month="%s" year="%d" />' % (som.strftime('%B'), som.year),'<days>']
183
184 cell=1
185 if day_diff.days>=30:
186- 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)]
187+ 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)]
188 else:
189 if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
190- 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)]
191+ 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)]
192 else:
193- 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)]
194+ 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)]
195
196 cell=x-som.day+1
197 day_diff1=day_diff.days-cell+1
198@@ -150,7 +150,7 @@
199 if month+i<=12:
200 if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
201 som1=datetime.date(year,month+i,1)
202- 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)]
203+ 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)]
204 i=i+1
205 j=j+1
206 month_dict[j]=som1.strftime('%B')
207@@ -159,7 +159,7 @@
208
209 else:
210 som1=datetime.date(year,month+i,1)
211- 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)]
212+ 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)]
213 i=i+1
214 j=j+1
215 month_dict[j]=som1.strftime('%B')
216@@ -174,7 +174,7 @@
217 i=1
218 if day_diff1>=30:
219 som1=datetime.date(years,i,1)
220- 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)]
221+ 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)]
222 i=i+1
223 j=j+1
224 month_dict[j]=som1.strftime('%B')
225@@ -186,7 +186,7 @@
226 i=i+1
227 j=j+1
228 month_dict[j]=som1.strftime('%B')
229- 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)]
230+ 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)]
231 cell=cell+x
232 width_dict[j]=x
233
234@@ -200,16 +200,16 @@
235 st+=',' + str(0.4 *width_dict[m])+'cm'
236 st+=',0.4cm</cols_months>\n'
237
238- months_xml =['<months number="%d" name="%s" />' % (x,month_dict[x]) for x in range(1,len(month_dict)+1) ]
239+ months_xml =['<months number="%d" name="%s"/>' % (x, _(month_dict[x])) for x in range(1,len(month_dict)+1) ]
240 months_xml.append(st)
241-
242+
243 emp_xml=''
244 row_id=1
245-
246+
247 if data['model']=='hr.employee':
248 for id in data['form']['emp']:
249 items = obj_emp.read(cr, uid, id, ['id','name'])
250-
251+
252 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, items['id'], items['name'], som, eom)
253 row_id = row_id +1
254
255@@ -229,7 +229,7 @@
256 dept_done=1
257 emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)
258 row_id = row_id +1
259-
260+
261 header_xml = '''
262 <header>
263 <date>%s</date>

Subscribers

People subscribed via source and target branches

to all changes: