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

Proposed by Laetitia Gangloff (Acsone)
Status: Merged
Merged at revision: 50
Proposed branch: lp:~acsone-openerp/hr-timesheet/7.0_fix_1200183
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Prerequisite: lp:~acsone-openerp/hr-timesheet/7.0_fix_1199795
Diff against target: 92 lines (+61/-4)
3 files modified
hr_attendance_analysis/__init__.py (+1/-0)
hr_attendance_analysis/hr_attendance.py (+4/-4)
hr_attendance_analysis/hr_contract.py (+56/-0)
To merge this branch: bzr merge lp:~acsone-openerp/hr-timesheet/7.0_fix_1200183
Reviewer Review Type Date Requested Status
Stéphane Bidoul (Acsone) (community) code review Approve
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+174173@code.launchpad.net

Description of the change

To post a comment you must log in.
49. By Laetitia Gangloff (Acsone)

hr_attandance_analysis: contract without trial period is not active contract.

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

'osv.osv' is deprecated, to replace by 'orm.Model'.

Are you sure you want to grant the copyright to Tiny SPRL?

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

hr_attendance_analysis: replace osv.osv by orm.Model ; replace copyright

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

Thank you for your review.

As you suggest I replace 'osv.osv' by 'orm.Model' and update the copyright.

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

Thanks, LGTM

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

LGTM

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_attendance_analysis/__init__.py'
--- hr_attendance_analysis/__init__.py 2013-03-08 11:08:23 +0000
+++ hr_attendance_analysis/__init__.py 2013-07-22 14:55:32 +0000
@@ -20,6 +20,7 @@
20#20#
21##############################################################################21##############################################################################
22import hr_attendance22import hr_attendance
23import hr_contract
23import report24import report
24import wizard25import wizard
25import resource26import resource
2627
=== modified file 'hr_attendance_analysis/hr_attendance.py'
--- hr_attendance_analysis/hr_attendance.py 2013-07-22 14:55:32 +0000
+++ hr_attendance_analysis/hr_attendance.py 2013-07-22 14:55:32 +0000
@@ -139,11 +139,11 @@
139 ('date_end', '>=', date),139 ('date_end', '>=', date),
140 ('date_end', '=', False),140 ('date_end', '=', False),
141 '&',141 '&',
142 '|',142 '&',
143 ('trial_date_start', '=', False),143 ('trial_date_start', '!=', False),
144 ('trial_date_start', '<=', date),144 ('trial_date_start', '<=', date),
145 '|',145 '&',
146 ('trial_date_end', '=', False),146 ('trial_date_end', '!=', False),
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:
150150
=== added file 'hr_attendance_analysis/hr_contract.py'
--- hr_attendance_analysis/hr_contract.py 1970-01-01 00:00:00 +0000
+++ hr_attendance_analysis/hr_contract.py 2013-07-22 14:55:32 +0000
@@ -0,0 +1,56 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Authors: Stéphane Bidoul & Laetitia Gangloff
5# Copyright (c) 2013 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28##############################################################################
29import datetime
30
31from openerp.osv import fields, orm
32
33
34class hr_contract(orm.Model):
35 _inherit = 'hr.contract'
36
37 def copy(self, cr, uid, id, defaults, context=None):
38 """
39 When duplicate a contract set the start date to the last end date + 1 day.
40 If the last end date is False, do nothing
41 """
42 contract = self.browse(cr, uid, id, context=context)
43 end_date_contract_id = self.search(cr, uid, [('employee_id', '=', contract.employee_id.id), ], limit=1, order='date_end desc', context=context)
44 last_end_date = False
45 if end_date_contract_id:
46 contract = self.browse(cr, uid, end_date_contract_id, context=context)
47 last_end_date = contract[0].date_end
48
49 if last_end_date:
50 defaults['date_start'] = datetime.datetime.strftime(datetime.datetime.strptime(last_end_date, "%Y-%m-%d") + datetime.timedelta(days=1), "%Y-%m-%d")
51 defaults['date_end'] = False
52 defaults['trial_date_start'] = False
53 defaults['trial_date_end'] = False
54 return super(hr_contract, self).copy(cr, uid, id, defaults, context=context)
55
56# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: