Merge lp:~openerp-groupes/hrself-addons/ampm into lp:hrself-addons
- ampm
- Merge into 6.0
Proposed by
Minh Tran (OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 528 |
Proposed branch: | lp:~openerp-groupes/hrself-addons/ampm |
Merge into: | lp:hrself-addons |
Diff against target: |
227 lines (+102/-38) 3 files modified
hrself_holidays/hrself_holidays.py (+2/-1) hrself_holidays/report/planned_leaves.py (+9/-6) hrself_holidays/report/planned_leaves.rml (+91/-31) |
To merge this branch: | bzr merge lp:~openerp-groupes/hrself-addons/ampm |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Ligot | Pending | ||
Review via email: mp+62108@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 530. By Olivier Ligot
-
[FIX] Leave types names are now displayed in the user language
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hrself_holidays/hrself_holidays.py' |
2 | --- hrself_holidays/hrself_holidays.py 2011-05-23 10:24:39 +0000 |
3 | +++ hrself_holidays/hrself_holidays.py 2011-05-24 13:49:36 +0000 |
4 | @@ -362,7 +362,8 @@ |
5 | for request in self.browse(cr, uid, ids, context=context): |
6 | if request.employee_id: |
7 | emp_name = request.employee_id.name |
8 | - labels[request.id] = "%s : %s" % (request.state, emp_name) |
9 | + ampm = request.am_pm != 'RH' and '[%s]' % (request.am_pm) or '' |
10 | + labels[request.id] = "%s %s : %s" % (ampm, request.state, emp_name) |
11 | return labels |
12 | |
13 | _columns = { |
14 | |
15 | === modified file 'hrself_holidays/report/planned_leaves.py' |
16 | --- hrself_holidays/report/planned_leaves.py 2011-05-12 20:00:01 +0000 |
17 | +++ hrself_holidays/report/planned_leaves.py 2011-05-24 13:49:36 +0000 |
18 | @@ -74,7 +74,7 @@ |
19 | """ |
20 | |
21 | while start <= end: |
22 | - if start.month == end.month: |
23 | + if start.month == end.month and start.year == end.year: |
24 | duration = end.day |
25 | else: |
26 | duration = calendar.monthrange(start.year, start.month)[1] |
27 | @@ -92,7 +92,7 @@ |
28 | employee_object = self.pool.get('hr.employee') |
29 | leave_object = self.pool.get('hrself.holidays.request.leave') |
30 | |
31 | - employees = employee_object.browse(self.cr, self.uid, form['employee_ids']) |
32 | + employees = sorted(employee_object.browse(self.cr, self.uid, form['employee_ids']), key=lambda employee: employee.name) |
33 | start_date = to_date(form['date_from']) |
34 | end_date = to_date(form['date_to']) |
35 | |
36 | @@ -108,20 +108,23 @@ |
37 | day_range = range(date.day, date.day + duration) |
38 | from collections import defaultdict |
39 | leave_color_by_day = defaultdict(lambda: DEFAULT_BACKGROUND_COLOR) |
40 | + ampm = defaultdict(lambda: 'RH') |
41 | for leave in leave_object.browse(self.cr, self.uid, leave_ids): |
42 | # a leave could span across previous and/or next month |
43 | for day in day_range: |
44 | if date.replace(day=day) in period(leave.date_from, leave.date_to): |
45 | leave_color_by_day[day] = leave.type_id.color_name |
46 | - emps_leaves.append(ReportData({'employee_name': employee.name_get()[0][1], 'leave_color_by_day': leave_color_by_day})) |
47 | + ampm[day] = leave.am_pm |
48 | + emps_leaves.append(ReportData({'employee_name': employee.name_get()[0][1], 'leave_color_by_day': leave_color_by_day, 'ampm': ampm})) |
49 | datas.append(ReportData({'date': date, 'emps_leaves': emps_leaves})) |
50 | - return datas |
51 | + return datas |
52 | |
53 | def holidays_types(self): |
54 | """HRSelf holidays types.""" |
55 | type_object = self.pool.get('hrself.holidays.type') |
56 | type_ids = type_object.search(self.cr, self.uid, []) |
57 | - return type_object.browse(self.cr, self.uid, type_ids) |
58 | + holidays_types = type_object.read(self.cr, self.uid, type_ids, ['name', 'color_name'], context=self.localcontext) |
59 | + return [ReportData(holidays_type) for holidays_type in holidays_types] |
60 | |
61 | from lxml import etree |
62 | import base64 |
63 | @@ -142,7 +145,7 @@ |
64 | rml_parser.set_context(objs, data, ids, report_xml.report_type) |
65 | |
66 | # our single enhancement: mako preprocessing with same parser context |
67 | - rml = Template(rml).render(**rml_parser.localcontext) |
68 | + rml = Template(rml).render_unicode(**rml_parser.localcontext) |
69 | |
70 | processed_rml = etree.XML(rml) |
71 | if report_xml.header: |
72 | |
73 | === modified file 'hrself_holidays/report/planned_leaves.rml' |
74 | --- hrself_holidays/report/planned_leaves.rml 2011-05-12 20:00:01 +0000 |
75 | +++ hrself_holidays/report/planned_leaves.rml 2011-05-24 13:49:36 +0000 |
76 | @@ -16,12 +16,12 @@ |
77 | <setFont name="Helvetica-Bold" size="9"/> |
78 | <!--TODO: see why the next line does not work... |
79 | <drawString x="1.3cm" y="19.70cm">[[ user.employee_id.universe_id.name ]]</drawString>--> |
80 | - <drawString x="1.3cm" y="19.70cm">[[ universe.name ]]</drawString> |
81 | - <drawString x="26.00cm" y="19.70cm">[[ report_name ]]</drawString> |
82 | + <drawString x="1.3cm" y="19.70cm">${universe.name}</drawString> |
83 | + <drawString x="26.00cm" y="19.70cm">${report_name}</drawString> |
84 | |
85 | <!-- footer --> |
86 | <setFont name="Helvetica" size="9"/> |
87 | - <drawString x="1.3cm" y="0.90cm">[[ formatLang(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), date_time = True) ]]</drawString> |
88 | + <drawString x="1.3cm" y="0.90cm">${formatLang(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), date_time = True)}</drawString> |
89 | <drawString x="27.50cm" y="0.90cm"> <pageNumber/></drawString> |
90 | |
91 | <lineMode width="0.7"/> |
92 | @@ -58,47 +58,107 @@ |
93 | <paraStyle name="terp_default_10" fontName="Helvetica" fontSize="10.0" leftIndent="-6.0" rightIndent="-6.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
94 | <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
95 | <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
96 | - <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
97 | + <paraStyle name="terp_default_9" fontName="Courier-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
98 | <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
99 | <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
100 | <paraStyle name="holidays_type_name" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceAfter="6.0" spaceBefore="6.0"/> |
101 | <paraStyle name="blank_space" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceAfter="6.0" spaceBefore="12.0"/> |
102 | <images/> |
103 | </stylesheet> |
104 | - |
105 | + <%! |
106 | + def ellipsis(length): |
107 | + def wrapped(text): |
108 | + if len(text) > length + 3: |
109 | + return "%s..." % text[0:length] |
110 | + else: |
111 | + return text |
112 | + return wrapped |
113 | + %> |
114 | <story> |
115 | - <para style="terp_header">[[ title(data['form']) ]]</para> |
116 | + <para style="terp_header">${title(data['form'])}</para> |
117 | <section> |
118 | - <para style="terp_default_8">[[ repeatIn(get_employees_leave_data(data['form']), 'employee_leave_data') ]]</para> |
119 | - <blockTable colWidths="3.5cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm,0.7cm" style="month" repeatRows="1"> |
120 | + % for leave_data in get_employees_leave_data(data['form']): |
121 | + <blockTable colWidths="8.4cm${',0.6cm'*31}" style="month" repeatRows="1" rowHeights="16"> |
122 | <tr> |
123 | - <td><para style="terp_tblheader_Details_Centre">[[ month_name(employee_leave_data.date.month) ]]-[[ str(employee_leave_data.date.year) ]]</para></td> |
124 | - % for i in range(1, 29): |
125 | - <td><para style="terp_default_8">${title(data['form'])}</para></td> |
126 | - % endfor |
127 | - <td><para style="terp_default_8">[[ month_length(employee_leave_data.date) >= 29 and 29 or removeParentNode('td') ]]</para></td> |
128 | - <td><para style="terp_default_8">[[ month_length(employee_leave_data.date) >= 30 and 30 or removeParentNode('td') ]]</para></td> |
129 | - <td><para style="terp_default_8">[[ month_length(employee_leave_data.date) >= 31 and 31 or removeParentNode('td') ]]</para></td> |
130 | + <td><para style="terp_tblheader_Details_Centre">${month_name(leave_data['date'].month)} ${leave_data['date'].year}</para></td> |
131 | + % for i in range(month_length(leave_data['date'])): |
132 | + <td><para style="terp_default_8">${i+1}</para></td> |
133 | + % endfor |
134 | + % for i in range(31-month_length(leave_data['date'])): |
135 | + <td><para style="terp_default_8"></para></td> |
136 | + % endfor |
137 | </tr> |
138 | + % for leave in leave_data['emps_leaves']: |
139 | <tr> |
140 | - <td><para style="terp_default_9">[[ repeatIn(employee_leave_data.emps_leaves, 'emps_leaves') ]] [[ emps_leaves.employee_name ]]</para></td> |
141 | + <td> <para style="terp_default_9">${leave['employee_name'] | ellipsis(38)}</para> </td> |
142 | % for i in range(1, 32): |
143 | - <td><para style="terp_default_10"><font> [[ setTag('para','para', {'backColor': emps_leaves.leave_color_by_day[${i}]}) ]] </font></para></td> |
144 | + <td> |
145 | + % if leave['leave_color_by_day'][i]: |
146 | + <illustration> |
147 | + <fill color="${leave['leave_color_by_day'][i]}" /> |
148 | + % if leave['ampm'][i] == 'RH': |
149 | + <rect x="-5" y="-12" width="15" height="14" fill="yes" stroke="false"/> |
150 | + % elif leave['ampm'][i] == 'AM': |
151 | + <path x="-5" y="-12" fill="yes" stroke="false"> |
152 | + -5 2 11 2 |
153 | + </path> |
154 | + % else: |
155 | + <path x="-5" y="-12" fill="yes" stroke="false"> |
156 | + 11 -12 11 2 |
157 | + </path> |
158 | + % endif |
159 | + </illustration> |
160 | + % endif |
161 | + </td> |
162 | % endfor |
163 | - </tr> |
164 | + </tr> |
165 | + % endfor |
166 | </blockTable> |
167 | - </section> |
168 | - <para style="blank_space"> |
169 | - <font/> |
170 | - </para> |
171 | - <section> |
172 | - <para style="terp_default_8">[[ repeatIn(holidays_types(), 'type')]]</para> |
173 | - <blockTable colWidths=" 24.5cm,0.7cm" style="legend"> |
174 | - <tr> |
175 | - <td><para style="holidays_type_name">[[ type.name_get({'lang': lang})[0][1] ]]</para></td> |
176 | - <td><para style="terp_default_10"><font> [[ setTag('para','para', {'backColor': type.color_name}) ]] </font></para></td> |
177 | - </tr> |
178 | - </blockTable> |
179 | - </section> |
180 | + % endfor |
181 | + </section> |
182 | + |
183 | + <para style="blank_space"> |
184 | + <font/> |
185 | + </para> |
186 | + |
187 | + <section> |
188 | + % for type in holidays_types(): |
189 | + <blockTable colWidths=" 24.5cm,0.6cm" style="legend"> |
190 | + <tr> |
191 | + <td><para style="holidays_type_name">${type.name}</para></td> |
192 | + <td><para style="terp_default_10" backColor="${type.color_name}"><font> </font></para></td> |
193 | + </tr> |
194 | + </blockTable> |
195 | + % endfor |
196 | + </section> |
197 | + <section> |
198 | + <blockTable colWidths=" 24.5cm,0.6cm" style="legend"> |
199 | + <tr> |
200 | + <td><para style="holidays_type_name">All day</para></td> |
201 | + <td> |
202 | + <illustration> |
203 | + <rect x="-6" y="-11" width="14" height="11"/> |
204 | + </illustration> |
205 | + </td> |
206 | + </tr> |
207 | + <tr> |
208 | + <td><para style="holidays_type_name">AM</para></td> |
209 | + <td> |
210 | + <illustration> |
211 | + <path x="-6" y="-11">-6 0 8 0</path> |
212 | + </illustration> |
213 | + </td> |
214 | + </tr> |
215 | + <tr> |
216 | + <td><para style="holidays_type_name">PM</para></td> |
217 | + <td> |
218 | + <illustration> |
219 | + <path x="-6" y="-11">8 -11 8 0</path> |
220 | + </illustration> |
221 | + </td> |
222 | + </tr> |
223 | + </blockTable> |
224 | + </section> |
225 | + |
226 | </story> |
227 | </document> |