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
1=== modified file 'hr_attendance_analysis/hr_attendance.py'
2--- hr_attendance_analysis/hr_attendance.py 2013-07-16 07:42:28 +0000
3+++ hr_attendance_analysis/hr_attendance.py 2013-07-16 07:42:28 +0000
4@@ -64,7 +64,7 @@
5 if hours / 24 > 0:
6 days += hours / 24
7 hours = hours % 24
8- return datetime(1900, 1, days, hours, minutes)
9+ return datetime(1900, 1, int(days), hours, minutes)
10
11 def float_to_timedelta(self, float_val):
12 str_time = self.float_time_convert(float_val)
13@@ -76,7 +76,7 @@
14
15 def time_difference(self, float_start_time, float_end_time):
16 if float_end_time < float_start_time:
17- raise osv.except_osv(_('Error'), _('End time %s < start time %s')
18+ raise orm.except_orm(_('Error'), _('End time %s < start time %s')
19 % (str(float_end_time),str(float_start_time)))
20 delta = self.float_to_datetime(float_end_time) - self.float_to_datetime(
21 float_start_time)
22@@ -147,9 +147,10 @@
23 ('trial_date_end', '>=', date),
24 ])
25 if len(active_contract_ids) > 1:
26- raise osv.except_osv(_('Error'), _(
27+ employee = self.pool.get('hr.employee').browse(cr,uid,employee_id)
28+ raise orm.except_orm(_('Error'), _(
29 'Too many active contracts for employee %s'
30- ) % attendance.employee_id.name)
31+ ) % employee.name)
32 return active_contract_ids
33
34 def _ceil_rounding(self, rounding, datetime):
35@@ -191,7 +192,7 @@
36 next_attendance = self.browse(cr, uid, next_attendance_ids[0])
37 if next_attendance.action == 'sign_in':
38 # 2012.10.16 LF FIX : Attendance in context timezone
39- raise osv.except_osv(_('Error'), _(
40+ raise orm.except_orm(_('Error'), _(
41 'Incongruent data: sign-in %s is followed by another sign-in'
42 ) % attendance_start)
43 next_attendance_date = next_attendance.name
44@@ -273,7 +274,7 @@
45 ('hour_from','<=',centered_attendance_hour),
46 ])
47 if len(matched_schedule_ids) > 1:
48- raise osv.except_osv(_('Error'),
49+ raise orm.except_orm(_('Error'),
50 _('Wrongly configured working schedule with id %s') % str(calendar_id))
51 if matched_schedule_ids:
52 intervals_within += 1
53
54=== modified file 'hr_attendance_analysis/wizard/print_calendar_report.py'
55--- hr_attendance_analysis/wizard/print_calendar_report.py 2013-05-31 10:15:39 +0000
56+++ hr_attendance_analysis/wizard/print_calendar_report.py 2013-07-16 07:42:28 +0000
57@@ -83,7 +83,7 @@
58 from_date = datetime.strptime(form['from_date'], '%Y-%m-%d')
59 to_date = datetime.strptime(form['to_date'], '%Y-%m-%d')
60 if from_date > to_date:
61- raise osv.except_osv(_('Error'), _('From date must be < to date'))
62+ raise orm.except_orm(_('Error'), _('From date must be < to date'))
63 employee_ids=form['employee_ids']
64 delta = to_date - from_date
65 max_number_of_attendances_per_day = 0
66@@ -172,7 +172,7 @@
67 calendar_attendance_duration = attendance_pool.time_difference(
68 calendar_attendance.hour_from, calendar_attendance.hour_to)
69 if calendar_attendance_duration < 0:
70- raise osv.except_osv(_('Error'),
71+ raise orm.except_orm(_('Error'),
72 _("%s: 'Work to' is < 'Work from'")
73 % calendar_attendance.name)
74 current_total_due = attendance_pool.time_sum(current_total_due,