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