Merge lp:~acsone-openerp/hr-timesheet/7.0_fix_1199795 into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Laetitia Gangloff (Acsone)
Status: Merged
Merged at revision: 49
Proposed branch: lp:~acsone-openerp/hr-timesheet/7.0_fix_1199795
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Prerequisite: lp:~elbati/hr-timesheet/7.0_fix_1193384_elbati
Diff against target: 74 lines (+9/-8)
2 files modified
hr_attendance_analysis/hr_attendance.py (+7/-6)
hr_attendance_analysis/wizard/print_calendar_report.py (+2/-2)
To merge this branch: bzr merge lp:~acsone-openerp/hr-timesheet/7.0_fix_1199795
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review, no test Approve
Stéphane Bidoul (Acsone) (community) code review Approve
Lorenzo Battistini (community) Approve
Review via email: mp+173982@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Instead of importing osv, use except_orm

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

hr_attendance_analysis: replace osv.except_osv by orm.except_orm

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

Hello,

as you suggest, I replace all osv.except_osv by orm.except_orm.

Thank you,
Laetitia

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

Thanks

review: Approve
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

LGTM

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

LGTM

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_attendance_analysis/hr_attendance.py'
--- hr_attendance_analysis/hr_attendance.py 2013-07-16 07:42:28 +0000
+++ hr_attendance_analysis/hr_attendance.py 2013-07-16 07:42:28 +0000
@@ -64,7 +64,7 @@
64 if hours / 24 > 0:64 if hours / 24 > 0:
65 days += hours / 2465 days += hours / 24
66 hours = hours % 2466 hours = hours % 24
67 return datetime(1900, 1, days, hours, minutes)67 return datetime(1900, 1, int(days), hours, minutes)
6868
69 def float_to_timedelta(self, float_val):69 def float_to_timedelta(self, float_val):
70 str_time = self.float_time_convert(float_val)70 str_time = self.float_time_convert(float_val)
@@ -76,7 +76,7 @@
7676
77 def time_difference(self, float_start_time, float_end_time):77 def time_difference(self, float_start_time, float_end_time):
78 if float_end_time < float_start_time:78 if float_end_time < float_start_time:
79 raise osv.except_osv(_('Error'), _('End time %s < start time %s')79 raise orm.except_orm(_('Error'), _('End time %s < start time %s')
80 % (str(float_end_time),str(float_start_time)))80 % (str(float_end_time),str(float_start_time)))
81 delta = self.float_to_datetime(float_end_time) - self.float_to_datetime(81 delta = self.float_to_datetime(float_end_time) - self.float_to_datetime(
82 float_start_time)82 float_start_time)
@@ -147,9 +147,10 @@
147 ('trial_date_end', '>=', date),147 ('trial_date_end', '>=', date),
148 ])148 ])
149 if len(active_contract_ids) > 1:149 if len(active_contract_ids) > 1:
150 raise osv.except_osv(_('Error'), _(150 employee = self.pool.get('hr.employee').browse(cr,uid,employee_id)
151 raise orm.except_orm(_('Error'), _(
151 'Too many active contracts for employee %s'152 'Too many active contracts for employee %s'
152 ) % attendance.employee_id.name)153 ) % employee.name)
153 return active_contract_ids154 return active_contract_ids
154155
155 def _ceil_rounding(self, rounding, datetime):156 def _ceil_rounding(self, rounding, datetime):
@@ -191,7 +192,7 @@
191 next_attendance = self.browse(cr, uid, next_attendance_ids[0])192 next_attendance = self.browse(cr, uid, next_attendance_ids[0])
192 if next_attendance.action == 'sign_in':193 if next_attendance.action == 'sign_in':
193 # 2012.10.16 LF FIX : Attendance in context timezone194 # 2012.10.16 LF FIX : Attendance in context timezone
194 raise osv.except_osv(_('Error'), _(195 raise orm.except_orm(_('Error'), _(
195 'Incongruent data: sign-in %s is followed by another sign-in'196 'Incongruent data: sign-in %s is followed by another sign-in'
196 ) % attendance_start)197 ) % attendance_start)
197 next_attendance_date = next_attendance.name198 next_attendance_date = next_attendance.name
@@ -273,7 +274,7 @@
273 ('hour_from','<=',centered_attendance_hour),274 ('hour_from','<=',centered_attendance_hour),
274 ])275 ])
275 if len(matched_schedule_ids) > 1:276 if len(matched_schedule_ids) > 1:
276 raise osv.except_osv(_('Error'),277 raise orm.except_orm(_('Error'),
277 _('Wrongly configured working schedule with id %s') % str(calendar_id))278 _('Wrongly configured working schedule with id %s') % str(calendar_id))
278 if matched_schedule_ids:279 if matched_schedule_ids:
279 intervals_within += 1280 intervals_within += 1
280281
=== modified file 'hr_attendance_analysis/wizard/print_calendar_report.py'
--- hr_attendance_analysis/wizard/print_calendar_report.py 2013-05-31 10:15:39 +0000
+++ hr_attendance_analysis/wizard/print_calendar_report.py 2013-07-16 07:42:28 +0000
@@ -83,7 +83,7 @@
83 from_date = datetime.strptime(form['from_date'], '%Y-%m-%d')83 from_date = datetime.strptime(form['from_date'], '%Y-%m-%d')
84 to_date = datetime.strptime(form['to_date'], '%Y-%m-%d')84 to_date = datetime.strptime(form['to_date'], '%Y-%m-%d')
85 if from_date > to_date:85 if from_date > to_date:
86 raise osv.except_osv(_('Error'), _('From date must be < to date'))86 raise orm.except_orm(_('Error'), _('From date must be < to date'))
87 employee_ids=form['employee_ids']87 employee_ids=form['employee_ids']
88 delta = to_date - from_date88 delta = to_date - from_date
89 max_number_of_attendances_per_day = 089 max_number_of_attendances_per_day = 0
@@ -172,7 +172,7 @@
172 calendar_attendance_duration = attendance_pool.time_difference(172 calendar_attendance_duration = attendance_pool.time_difference(
173 calendar_attendance.hour_from, calendar_attendance.hour_to)173 calendar_attendance.hour_from, calendar_attendance.hour_to)
174 if calendar_attendance_duration < 0:174 if calendar_attendance_duration < 0:
175 raise osv.except_osv(_('Error'),175 raise orm.except_orm(_('Error'),
176 _("%s: 'Work to' is < 'Work from'")176 _("%s: 'Work to' is < 'Work from'")
177 % calendar_attendance.name)177 % calendar_attendance.name)
178 current_total_due = attendance_pool.time_sum(current_total_due, 178 current_total_due = attendance_pool.time_sum(current_total_due,