Merge lp:~laetitia-gangloff/hr-timesheet/hr_attendance_analysis_externalise_contract_calendar into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Laetitia Gangloff (Acsone)
Status: Superseded
Proposed branch: lp:~laetitia-gangloff/hr-timesheet/hr_attendance_analysis_externalise_contract_calendar
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 458 lines (+140/-98) (has conflicts)
2 files modified
hr_attendance_analysis/hr_attendance.py (+69/-46)
hr_attendance_analysis/wizard/print_calendar_report.py (+71/-52)
Text conflict in hr_attendance_analysis/hr_attendance.py
Text conflict in hr_attendance_analysis/wizard/print_calendar_report.py
To merge this branch: bzr merge lp:~laetitia-gangloff/hr-timesheet/hr_attendance_analysis_externalise_contract_calendar
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Guewen Baconnier @ Camptocamp Needs Resubmitting
Lorenzo Battistini (community) Needs Fixing
Review via email: mp+182565@code.launchpad.net

This proposal has been superseded by a proposal from 2013-11-19.

Description of the change

In order to be able to use another calendar in some extension modules:
- rename get_active_contracts to get_reference_calendar and return the possible calendar attached to retrieve contract
- update code to take account of this change (_get_attendance_duration and print_calendar method)
- externalise store part of column in _store_rules to easily extends it

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Lorenzo Battistini (elbati) wrote :
review: Needs Fixing
54. By Laetitia Gangloff (Acsone)

hr_attendance_analysis: externalise contract calendar

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Oh right !
and all following lines are shifted.

Thank you for your review. I corrected this mistake.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

There are conflicts.

Your last commit
http://bazaar.launchpad.net/~laetitia-gangloff/hr-timesheet/hr_attendance_analysis_externalise_contract_calendar/revision/54
did a lot of changes

I suggest to revert to revision 53 and make the changes related to line 235 only.

Thanks

review: Needs Fixing
55. By Laetitia Gangloff (Acsone)

revert last commit

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

There are still conflicts. Can you check ?

review: Needs Resubmitting
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/hr-timesheet. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

I think, the state of this mp/branch is not correct.
The purpose of this mp, is already in hr-timesheet project at revision 62.

What is the best pratice to remove the mp and the branch ?

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

This one is set as Superseeded. Seems fine. No change needed.

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Super !
Thank you, I set the branch has abandonned.

Unmerged revisions

55. By Laetitia Gangloff (Acsone)

revert last commit

54. By Laetitia Gangloff (Acsone)

hr_attendance_analysis: externalise contract calendar

53. By Laetitia Gangloff (Acsone)

hr_attendance_analysis: externalise contract calendar

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_attendance_analysis/hr_attendance.py'
2--- hr_attendance_analysis/hr_attendance.py 2013-08-30 10:27:51 +0000
3+++ hr_attendance_analysis/hr_attendance.py 2013-09-10 14:55:43 +0000
4@@ -127,7 +127,9 @@
5 res.append((start_datetime, precision))
6 return res
7
8- def get_active_contracts(self, cr, uid, employee_id, date=datetime.now().strftime('%Y-%m-%d')):
9+ def get_reference_calendar(self, cr, uid, employee_id, date=None, context=None):
10+ if date is None:
11+ date = fields.date.context_today(self, cr, uid, context=context)
12 contract_pool = self.pool.get('hr.contract')
13 active_contract_ids= contract_pool.search(cr, uid, [
14 '&',
15@@ -145,12 +147,24 @@
16 '&',
17 ('trial_date_end', '!=', False),
18 ('trial_date_end', '>=', date),
19- ])
20+ ], context=context)
21 if len(active_contract_ids) > 1:
22+<<<<<<< TREE
23 employee = self.pool.get('hr.employee').browse(cr,uid,employee_id)
24 raise orm.except_orm(_('Error'), _(
25+=======
26+ employee = self.pool.get('hr.employee').browse(cr,uid,employee_id, context=context)
27+ raise orm.except_orm(_('Error'), _(
28+>>>>>>> MERGE-SOURCE
29 'Too many active contracts for employee %s'
30- ) % employee.name)
31+<<<<<<< TREE
32+ ) % employee.name)
33+=======
34+ ) % employee.name)
35+ if active_contract_ids:
36+ contract = contract_pool.browse(cr, uid, active_contract_ids[0], context=context)
37+ return contract.working_hours
38+>>>>>>> MERGE-SOURCE
39 return active_contract_ids
40
41 def _ceil_rounding(self, rounding, datetime):
42@@ -165,10 +179,9 @@
43
44 def _get_attendance_duration(self, cr, uid, ids, field_name, arg, context=None):
45 res = {}
46- contract_pool = self.pool.get('hr.contract')
47 resource_pool = self.pool.get('resource.resource')
48 attendance_pool = self.pool.get('resource.calendar.attendance')
49- precision = self.pool.get('res.users').browse(cr, uid, uid).company_id.working_time_precision
50+ precision = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.working_time_precision
51 # 2012.10.16 LF FIX : Get timezone from context
52 active_tz = pytz.timezone(context.get("tz","UTC") if context else "UTC")
53 str_now = datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')
54@@ -176,7 +189,7 @@
55 duration = 0.0
56 outside_calendar_duration = 0.0
57 inside_calendar_duration = 0.0
58- attendance = self.browse(cr, uid, attendance_id)
59+ attendance = self.browse(cr, uid, attendance_id, context=context)
60 res[attendance.id] = {}
61 # 2012.10.16 LF FIX : Attendance in context timezone
62 attendance_start = datetime.strptime(
63@@ -188,9 +201,9 @@
64 if attendance.action == 'sign_in':
65 next_attendance_ids = self.search(cr, uid, [
66 ('employee_id', '=', attendance.employee_id.id),
67- ('name', '>', attendance.name)], order='name')
68+ ('name', '>', attendance.name)], order='name', context=context)
69 if next_attendance_ids:
70- next_attendance = self.browse(cr, uid, next_attendance_ids[0])
71+ next_attendance = self.browse(cr, uid, next_attendance_ids[0], context=context)
72 if next_attendance.action == 'sign_in':
73 # 2012.10.16 LF FIX : Attendance in context timezone
74 raise orm.except_orm(_('Error'), _(
75@@ -206,13 +219,14 @@
76 duration = round(duration / precision) * precision
77 res[attendance.id]['duration'] = duration
78 res[attendance.id]['end_datetime'] = next_attendance_date
79- # If contract is not specified: working days = 24/7
80+ # If calendar is not specified: working days = 24/7
81 res[attendance.id]['inside_calendar_duration'] = duration
82 res[attendance.id]['outside_calendar_duration'] = 0.0
83
84- active_contract_ids = self.get_active_contracts(
85- cr, uid, attendance.employee_id.id, date=str_now[:10])
86+ reference_calendar = self.get_reference_calendar(
87+ cr, uid, attendance.employee_id.id, date=str_now[:10], context=context)
88
89+<<<<<<< TREE
90 if active_contract_ids and next_attendance_ids:
91 contract = contract_pool.browse(cr, uid, active_contract_ids[0])
92 if contract.working_hours:
93@@ -224,6 +238,23 @@
94 rounded_stop_hour = self._floor_rounding(
95 float_attendance_rounding, attendance_stop)
96
97+=======
98+ if reference_calendar and next_attendance_ids:
99+ # TODO applicare prima arrotondamento o tolleranza?
100+ if reference_calendar.attendance_rounding:
101+ float_attendance_rounding = float(reference_calendar.attendance_rounding)
102+ rounded_start_hour = self._ceil_rounding(
103+ float_attendance_rounding, attendance_start)
104+ rounded_stop_hour = self._floor_rounding(
105+ float_attendance_rounding, attendance_stop)
106+
107+ if abs(1- rounded_start_hour) < 0.01: # if shift == 1 hour
108+ attendance_start = datetime(attendance_start.year, attendance_start.month,
109+ attendance_start.day, attendance_start.hour + 1)
110+ else:
111+ attendance_start = datetime(attendance_start.year, attendance_start.month,
112+ attendance_start.day, attendance_start.hour, int(round(rounded_start_hour * 60.0)))
113+>>>>>>> MERGE-SOURCE
114 if abs(1- rounded_start_hour) < 0.01: # if shift == 1 hour
115 attendance_start = datetime(attendance_start.year, attendance_start.month,
116 attendance_start.day, attendance_start.hour + 1)
117@@ -243,7 +274,7 @@
118
119 res[attendance.id]['inside_calendar_duration'] = 0.0
120 res[attendance.id]['outside_calendar_duration'] = 0.0
121- calendar_id = contract.working_hours.id
122+ calendar_id = reference_calendar.id
123 intervals_within = 0
124
125 # split attendance in intervals = precision
126@@ -273,7 +304,7 @@
127 ('calendar_id','=',calendar_id),
128 ('hour_to','>=',centered_attendance_hour),
129 ('hour_from','<=',centered_attendance_hour),
130- ])
131+ ], context=context)
132 if len(matched_schedule_ids) > 1:
133 raise orm.except_orm(_('Error'),
134 _('Wrongly configured working schedule with id %s') % str(calendar_id))
135@@ -281,7 +312,7 @@
136 intervals_within += 1
137 # sign in tolerance
138 if intervals_within == 1:
139- calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0])
140+ calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0], context=context)
141 attendance_start_hour = (
142 attendance_start.hour + attendance_start.minute / 60.0
143 + attendance_start.second / 60.0 / 60.0
144@@ -302,7 +333,7 @@
145 attendance_stop.hour + attendance_stop.minute / 60.0
146 + attendance_stop.second / 60.0 / 60.0
147 )
148- calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0])
149+ calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0], context=context)
150 if attendance_stop_hour <= (
151 calendar_attendance.hour_to and
152 (attendance_stop_hour - (calendar_attendance.hour_to -
153@@ -321,13 +352,13 @@
154 res[attendance.id]['inside_calendar_duration'],
155 res[attendance.id]['duration'])
156
157- if contract.working_hours.overtime_rounding:
158+ if reference_calendar.overtime_rounding:
159 if res[attendance.id]['outside_calendar_duration']:
160 overtime = res[attendance.id]['outside_calendar_duration']
161- if contract.working_hours.overtime_rounding_tolerance:
162+ if reference_calendar.overtime_rounding_tolerance:
163 overtime = self.time_sum(overtime,
164- contract.working_hours.overtime_rounding_tolerance)
165- float_overtime_rounding = float(contract.working_hours.overtime_rounding)
166+ reference_calendar.overtime_rounding_tolerance)
167+ float_overtime_rounding = float(reference_calendar.overtime_rounding)
168 res[attendance.id]['outside_calendar_duration'] = math.floor(
169 overtime * float_overtime_rounding) / float_overtime_rounding
170
171@@ -337,7 +368,7 @@
172 attendance_ids = []
173 attendance_pool = self.pool.get('hr.attendance')
174 for contract in self.pool.get('hr.contract').browse(cr, uid, ids, context=context):
175- att_ids = attendance_pool.search(cr, uid, [('employee_id', '=', contract.employee_id.id)])
176+ att_ids = attendance_pool.search(cr, uid, [('employee_id', '=', contract.employee_id.id)], context=context)
177 for att_id in att_ids:
178 if att_id not in attendance_ids:
179 attendance_ids.append(att_id)
180@@ -348,7 +379,7 @@
181 attendance_pool = self.pool.get('hr.attendance')
182 contract_pool = self.pool.get('hr.contract')
183 for calendar in self.pool.get('resource.calendar').browse(cr, uid, ids, context=context):
184- contract_ids = contract_pool.search(cr, uid, [('working_hours', '=', calendar.id)])
185+ contract_ids = contract_pool.search(cr, uid, [('working_hours', '=', calendar.id)], context=context)
186 att_ids = attendance_pool._get_by_contracts(cr, uid, contract_ids, context=None)
187 for att_id in att_ids:
188 if att_id not in attendance_ids:
189@@ -373,47 +404,39 @@
190 elif attendance.action == 'sign_out':
191 previous_attendance_ids = self.search(cr, uid, [
192 ('employee_id', '=', attendance.employee_id.id),
193+<<<<<<< TREE
194 ('name', '<', attendance.name),
195 ('action', '=', 'sign_in'),
196 ], order='name')
197+=======
198+ ('name', '<', attendance.name),
199+ ('action', '=', 'sign_in'),
200+ ], order='name', context=context)
201+>>>>>>> MERGE-SOURCE
202 if previous_attendance_ids and previous_attendance_ids[len(previous_attendance_ids) - 1] not in attendance_ids:
203 attendance_ids.append(previous_attendance_ids[len(previous_attendance_ids) - 1])
204 return attendance_ids
205
206 _inherit = "hr.attendance"
207
208+ _store_rules = {
209+ 'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),
210+ 'hr.contract': (_get_by_contracts, ['employee_id', 'date_start', 'date_end', 'trial_date_start', 'trial_date_end', 'working_hours'], 20),
211+ 'resource.calendar': (_get_by_calendars, ['attendance_ids'], 20),
212+ 'resource.calendar.attendance': (_get_by_calendar_attendances, ['dayofweek', 'date_from', 'hour_from', 'hour_to', 'calendar_id'], 20),
213+ }
214+
215 _columns = {
216 'duration': fields.function(_get_attendance_duration, method=True, multi='duration', string="Attendance duration",
217- store={
218- 'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),
219- 'hr.contract': (_get_by_contracts, ['employee_id', 'date_start', 'date_end', 'trial_date_start', 'trial_date_end', 'working_hours'], 20),
220- 'resource.calendar': (_get_by_calendars, ['attendance_ids'], 20),
221- 'resource.calendar.attendance': (_get_by_calendar_attendances, ['dayofweek', 'date_from', 'hour_from', 'hour_to', 'calendar_id'], 20),
222- }
223- ),
224+ store=_store_rules),
225 'end_datetime': fields.function(_get_attendance_duration, method=True, multi='duration', type="datetime", string="End date time",
226- store={
227- 'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),
228- 'hr.contract': (_get_by_contracts, ['employee_id', 'date_start', 'date_end', 'trial_date_start', 'trial_date_end', 'working_hours'], 20),
229- 'resource.calendar': (_get_by_calendars, ['attendance_ids'], 20),
230- 'resource.calendar.attendance': (_get_by_calendar_attendances, ['dayofweek', 'date_from', 'hour_from', 'hour_to', 'calendar_id'], 20),
231- }),
232+ store=_store_rules),
233 'outside_calendar_duration': fields.function(_get_attendance_duration, method=True, multi='duration',
234 string="Overtime",
235- store={
236- 'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),
237- 'hr.contract': (_get_by_contracts, ['employee_id', 'date_start', 'date_end', 'trial_date_start', 'trial_date_end', 'working_hours'], 20),
238- 'resource.calendar': (_get_by_calendars, ['attendance_ids'], 20),
239- 'resource.calendar.attendance': (_get_by_calendar_attendances, ['dayofweek', 'date_from', 'hour_from', 'hour_to', 'calendar_id'], 20),
240- }),
241+ store=_store_rules),
242 'inside_calendar_duration': fields.function(_get_attendance_duration, method=True, multi='duration',
243 string="Duration within working schedule",
244- store={
245- 'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),
246- 'hr.contract': (_get_by_contracts, ['employee_id', 'date_start', 'date_end', 'trial_date_start', 'trial_date_end', 'working_hours'], 20),
247- 'resource.calendar': (_get_by_calendars, ['attendance_ids'], 20),
248- 'resource.calendar.attendance': (_get_by_calendar_attendances, ['dayofweek', 'date_from', 'hour_from', 'hour_to', 'calendar_id'], 20),
249- }),
250+ store=_store_rules),
251 }
252
253
254
255=== modified file 'hr_attendance_analysis/wizard/print_calendar_report.py'
256--- hr_attendance_analysis/wizard/print_calendar_report.py 2013-07-16 07:39:48 +0000
257+++ hr_attendance_analysis/wizard/print_calendar_report.py 2013-09-10 14:55:43 +0000
258@@ -55,7 +55,7 @@
259 'year': lambda * a: datetime.now().year,
260 'from_date': lambda * a: (datetime.now()-timedelta(30)).strftime('%Y-%m-%d'),
261 'to_date': lambda * a: datetime.now().strftime('%Y-%m-%d'),
262- 'employee_ids': lambda s, cr, uid, c: s.pool.get('hr.employee').search(cr, uid, []),
263+ 'employee_ids': lambda s, cr, uid, c: s.pool.get('hr.employee').search(cr, uid, [], context=None),
264 }
265
266 _name = "attendance_analysis.wizard.calendar_report"
267@@ -74,12 +74,11 @@
268 if context is None:
269 context = {}
270 attendance_pool = self.pool.get('hr.attendance')
271- contract_pool = self.pool.get('hr.contract')
272 holidays_pool = self.pool.get('hr.holidays')
273
274 days_by_employee = {}
275
276- form = self.read(cr, uid, ids)[0]
277+ form = self.read(cr, uid, ids, context=context)[0]
278 from_date = datetime.strptime(form['from_date'], '%Y-%m-%d')
279 to_date = datetime.strptime(form['to_date'], '%Y-%m-%d')
280 if from_date > to_date:
281@@ -97,7 +96,7 @@
282 current_total_attendances = 0.0
283 current_total_overtime = 0.0
284 current_total_leaves = 0.0
285- current_total_due = 24.0 # If contract is not specified: working days = 24/7
286+ current_total_due = 24.0 # If calendar is not specified: working days = 24/7
287 current_total_inside_calendar = 0.0
288 str_current_date = current_date.strftime('%Y-%m-%d')
289 days_by_employee[employee_id][str_current_date] = {
290@@ -121,9 +120,9 @@
291 ('name','>=',str_current_date_beginning),
292 ('name','<=',str_current_date_end),
293 ('action','=','sign_in'),
294- ])
295+ ], context=context)
296 # computing attendance totals
297- for attendance in attendance_pool.browse(cr, uid, attendance_ids):
298+ for attendance in attendance_pool.browse(cr, uid, attendance_ids, context=context):
299 current_total_attendances = attendance_pool.time_sum(
300 current_total_attendances,attendance.duration)
301 current_total_overtime = attendance_pool.time_sum(current_total_overtime,
302@@ -135,7 +134,7 @@
303 #printing up to 4 attendances
304 if len(attendance_ids) < 5:
305 count = 1
306- for attendance in sorted(attendance_pool.browse(cr, uid, attendance_ids),
307+ for attendance in sorted(attendance_pool.browse(cr, uid, attendance_ids, context=context),
308 key=lambda x: x['name']):
309 days_by_employee[employee_id][str_current_date][
310 'signin_'+str(count)] = attendance.name[11:16]
311@@ -152,9 +151,10 @@
312 'overtime'
313 ] = current_total_overtime
314
315- active_contract_ids = attendance_pool.get_active_contracts(
316- cr, uid, int(employee_id), date=str_current_date)
317+ reference_calendar = attendance_pool.get_reference_calendar(
318+ cr, uid, int(employee_id), date=str_current_date, context=context)
319 # computing due total
320+<<<<<<< TREE
321 if active_contract_ids:
322 contract = contract_pool.browse(cr, uid, active_contract_ids[0])
323 if contract.working_hours and contract.working_hours.attendance_ids:
324@@ -178,6 +178,29 @@
325 current_total_due = attendance_pool.time_sum(current_total_due,
326 calendar_attendance_duration)
327
328+=======
329+ if reference_calendar and reference_calendar.attendance_ids:
330+ current_total_due = 0.0
331+ for calendar_attendance in reference_calendar.attendance_ids:
332+ if ((
333+ not calendar_attendance.dayofweek
334+ or int(calendar_attendance.dayofweek) == current_date.weekday()
335+ )
336+ and (
337+ not calendar_attendance.date_from or
338+ datetime.strptime(calendar_attendance.date_from,'%Y-%m-%d')
339+ <= current_date
340+ )):
341+ calendar_attendance_duration = attendance_pool.time_difference(
342+ calendar_attendance.hour_from, calendar_attendance.hour_to)
343+ if calendar_attendance_duration < 0:
344+ raise orm.except_orm(_('Error'),
345+ _("%s: 'Work to' is < 'Work from'")
346+ % calendar_attendance.name)
347+ current_total_due = attendance_pool.time_sum(current_total_due,
348+ calendar_attendance_duration)
349+
350+>>>>>>> MERGE-SOURCE
351 days_by_employee[employee_id][str_current_date]['due'] = current_total_due
352
353 # computing leaves
354@@ -200,8 +223,8 @@
355 ('date_to', '>', str_current_date_end),
356 ('state', '=', 'validate'),
357 ('employee_id', '=', int(employee_id)),
358- ])
359- for holiday in holidays_pool.browse(cr, uid, holidays_ids):
360+ ], context=context)
361+ for holiday in holidays_pool.browse(cr, uid, holidays_ids, context=context):
362 date_from = datetime.strptime(holiday.date_from, '%Y-%m-%d %H:%M:%S')
363 date_to = datetime.strptime(holiday.date_to, '%Y-%m-%d %H:%M:%S')
364 # if beginned before today
365@@ -230,17 +253,15 @@
366 ] = attendance_pool.time_difference(
367 current_total_inside_calendar, due_minus_leaves)
368
369- if active_contract_ids:
370- contract = contract_pool.browse(cr, uid, active_contract_ids[0])
371- if contract.working_hours and contract.working_hours.leave_rounding:
372- float_rounding = float(contract.working_hours.leave_rounding)
373- days_by_employee[employee_id][str_current_date][
374- 'negative'
375- ] = math.floor(
376- days_by_employee[employee_id][str_current_date]['negative'] *
377- float_rounding
378- ) / float_rounding
379-
380+ if reference_calendar and reference_calendar.leave_rounding:
381+ float_rounding = float(reference_calendar.leave_rounding)
382+ days_by_employee[employee_id][str_current_date][
383+ 'negative'
384+ ] = math.floor(
385+ days_by_employee[employee_id][str_current_date]['negative'] *
386+ float_rounding
387+ ) / float_rounding
388+
389 day_count += 1
390
391 totals_by_employee = {}
392@@ -272,36 +293,34 @@
393 days_by_employee[employee_id][str_date]['due'])
394
395 # computing overtime types
396- active_contract_ids = attendance_pool.get_active_contracts(
397- cr, uid, int(employee_id), date=str_date)
398- if active_contract_ids:
399- contract = contract_pool.browse(cr, uid, active_contract_ids[0])
400- if contract.working_hours and contract.working_hours.overtime_type_ids:
401- sorted_types = sorted(
402- contract.working_hours.overtime_type_ids,
403- key=lambda k: k.sequence)
404- current_overtime = days_by_employee[employee_id][
405- str_date]['overtime']
406- for overtime_type in sorted_types:
407- if not totals_by_employee[employee_id]['total_types'].get(
408- overtime_type.name, False):
409- totals_by_employee[employee_id]['total_types'][
410- overtime_type.name] = 0.0
411- if current_overtime:
412- if current_overtime <= overtime_type.limit or not overtime_type.limit:
413- totals_by_employee[employee_id]['total_types'][
414- overtime_type.name] = attendance_pool.time_sum(
415- totals_by_employee[employee_id]
416- ['total_types'][overtime_type.name],
417- current_overtime)
418- current_overtime = 0.0
419- else:
420- totals_by_employee[employee_id]['total_types'][
421- overtime_type.name] = attendance_pool.time_sum(
422- totals_by_employee[employee_id]['total_types']
423- [overtime_type.name], overtime_type.limit)
424- current_overtime = attendance_pool.time_difference(overtime_type.limit,
425- current_overtime)
426+ reference_calendar = attendance_pool.get_reference_calendar(
427+ cr, uid, int(employee_id), date=str_date, context=context)
428+ if reference_calendar and reference_calendar.overtime_type_ids:
429+ sorted_types = sorted(
430+ reference_calendar.overtime_type_ids,
431+ key=lambda k: k.sequence)
432+ current_overtime = days_by_employee[employee_id][
433+ str_date]['overtime']
434+ for overtime_type in sorted_types:
435+ if not totals_by_employee[employee_id]['total_types'].get(
436+ overtime_type.name, False):
437+ totals_by_employee[employee_id]['total_types'][
438+ overtime_type.name] = 0.0
439+ if current_overtime:
440+ if current_overtime <= overtime_type.limit or not overtime_type.limit:
441+ totals_by_employee[employee_id]['total_types'][
442+ overtime_type.name] = attendance_pool.time_sum(
443+ totals_by_employee[employee_id]
444+ ['total_types'][overtime_type.name],
445+ current_overtime)
446+ current_overtime = 0.0
447+ else:
448+ totals_by_employee[employee_id]['total_types'][
449+ overtime_type.name] = attendance_pool.time_sum(
450+ totals_by_employee[employee_id]['total_types']
451+ [overtime_type.name], overtime_type.limit)
452+ current_overtime = attendance_pool.time_difference(overtime_type.limit,
453+ current_overtime)
454
455 days_by_employee[employee_id][str_date][
456 'attendances'
457
458=== modified file 'timesheet_task/project_task.py'