Merge lp:~agilebg/hr-timesheet/hr_attendance_analysis-imp-time_difference-message into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Lorenzo Battistini
Status: Work in progress
Proposed branch: lp:~agilebg/hr-timesheet/hr_attendance_analysis-imp-time_difference-message
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 86 lines (+28/-10)
2 files modified
hr_attendance_analysis/hr_attendance.py (+14/-6)
hr_attendance_analysis/wizard/print_calendar_report.py (+14/-4)
To merge this branch: bzr merge lp:~agilebg/hr-timesheet/hr_attendance_analysis-imp-time_difference-message
Reviewer Review Type Date Requested Status
Alex Comba - Agile BG (community) Disapprove
Pedro Manuel Baeza Needs Resubmitting
Review via email: mp+225275@code.launchpad.net

Description of the change

This allows, when time diff errors are raised, to identify the raising attendance

To post a comment you must log in.
71. By Lorenzo Battistini

[FIX] syntax error

72. By Lorenzo Battistini

[imp] wizard error messages

73. By Lorenzo Battistini

[IMP] wizard error message

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
Alex Comba - Agile BG (tafaru) wrote :

Moved to https://github.com/OCA/hr-timesheet/pull/7
I prefer do not delete the proposal to keep all the associated comments that have been made.

review: Disapprove

Unmerged revisions

73. By Lorenzo Battistini

[IMP] wizard error message

72. By Lorenzo Battistini

[imp] wizard error messages

71. By Lorenzo Battistini

[FIX] syntax error

70. By Lorenzo Battistini

[IMP] time_difference error msg
This allows, when time diff errors are raised, to identify the raising attendance

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 2014-05-21 22:04:08 +0000
3+++ hr_attendance_analysis/hr_attendance.py 2014-07-02 12:01:10 +0000
4@@ -75,16 +75,21 @@
5 def total_seconds(self, td):
6 return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
7
8- def time_difference(self, float_start_time, float_end_time):
9+ def time_difference(
10+ self, float_start_time, float_end_time, help_message=False
11+ ):
12 if float_compare(
13 float_end_time, float_start_time, precision_rounding=0.0000001
14 ) == -1:
15 # that means a difference smaller than 0.36 milliseconds
16+ message = _('End time %s < start time %s %s') % (
17+ str(float_end_time),
18+ str(float_start_time),
19+ help_message and '(' + help_message + ')' or ''
20+ )
21 raise orm.except_orm(
22 _('Error'),
23- _('End time %s < start time %s') % (
24- str(float_end_time), str(float_start_time)
25- )
26+ message
27 )
28 delta = self.float_to_datetime(
29 float_end_time) - self.float_to_datetime(
30@@ -329,9 +334,12 @@
31 res[attendance.id]['inside_calendar_duration'] = intervals_within * precision
32 # make difference using time in order to avoid rounding errors
33 # inside_calendar_duration can't be > duration
34- res[attendance.id]['outside_calendar_duration'] = self.time_difference(
35+ res[attendance.id][
36+ 'outside_calendar_duration'
37+ ] = self.time_difference(
38 res[attendance.id]['inside_calendar_duration'],
39- res[attendance.id]['duration'])
40+ res[attendance.id]['duration'],
41+ help_message='Attendance ID %s' % attendance.id)
42
43 if reference_calendar.overtime_rounding:
44 if res[attendance.id]['outside_calendar_duration']:
45
46=== modified file 'hr_attendance_analysis/wizard/print_calendar_report.py'
47--- hr_attendance_analysis/wizard/print_calendar_report.py 2013-11-19 13:32:00 +0000
48+++ hr_attendance_analysis/wizard/print_calendar_report.py 2014-07-02 12:01:10 +0000
49@@ -167,8 +167,14 @@
50 datetime.strptime(calendar_attendance.date_from,'%Y-%m-%d')
51 <= current_date
52 )):
53- calendar_attendance_duration = attendance_pool.time_difference(
54- calendar_attendance.hour_from, calendar_attendance.hour_to)
55+ calendar_attendance_duration = (
56+ attendance_pool.time_difference(
57+ calendar_attendance.hour_from,
58+ calendar_attendance.hour_to,
59+ help_message=(
60+ 'Calendar attendance ID %s'
61+ % calendar_attendance.id))
62+ )
63 if calendar_attendance_duration < 0:
64 raise orm.except_orm(_('Error'),
65 _("%s: 'Work to' is < 'Work from'")
66@@ -219,14 +225,18 @@
67 'leaves'
68 ] = days_by_employee[employee_id][str_current_date]['due']
69 due_minus_leaves = attendance_pool.time_difference(
70- current_total_leaves, current_total_due)
71+ current_total_leaves, current_total_due,
72+ help_message='Employee ID %s. Date %s' % (
73+ employee_id, str_current_date))
74 if due_minus_leaves < current_total_inside_calendar:
75 days_by_employee[employee_id][str_current_date]['negative'] = 0.0
76 else:
77 days_by_employee[employee_id][str_current_date][
78 'negative'
79 ] = attendance_pool.time_difference(
80- current_total_inside_calendar, due_minus_leaves)
81+ current_total_inside_calendar, due_minus_leaves,
82+ help_message='Employee ID %s. Date %s' % (
83+ employee_id, str_current_date))
84
85 if reference_calendar:
86 if reference_calendar.leave_rounding:

Subscribers

People subscribed via source and target branches