Merge lp:~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id into lp:openupgrade-addons/6.0

Proposed by Stefan Rijnhart (Opener) on 2012-07-19
Status: Merged
Merged at revision: 4785
Proposed branch: lp:~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id
Merge into: lp:openupgrade-addons/6.0
Diff against target: 50 lines (+13/-1)
3 files modified
hr/migrations/6.0.1.1/post-migration.py (+10/-0)
hr/migrations/6.0.1.1/pre-migration.py (+1/-1)
hr/migrations/6.0.1.1/user_notes.txt (+2/-0)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id
Reviewer Review Type Date Requested Status
Don Kirkby (community) 2012-07-19 Approve on 2012-07-19
OpenUpgrade Committers 2012-07-19 Pending
Review via email: mp+115698@code.launchpad.net

Description of the change

This branch restores the manually assigned employees' managers. I could not simply *not* rename the table, as other changes require the department_id to be written on the employee record. This triggers that the department_id's head is written as the manager on the employee record due to it being a stored related field (a change that was reverted in OpenERP 6.1 which warrants restoring the manager field this way in the first place).

To post a comment you must log in.
Don Kirkby (donkirkby) wrote :

Looks good, thanks for the fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr/migrations/6.0.1.1/post-migration.py'
2--- hr/migrations/6.0.1.1/post-migration.py 2012-06-07 14:51:52 +0000
3+++ hr/migrations/6.0.1.1/post-migration.py 2012-07-19 10:47:55 +0000
4@@ -91,6 +91,11 @@
5 to membership by employee.
6 In OpenERP 6, an employee can only be in a single
7 department.
8+
9+ When the department is written on the employee record,
10+ the manager is taken to be the head of the department in 6.0.
11+ This change was reverted in 6.1. To accomodate migrations to 6.1,
12+ restore the original manager
13 """
14 employee_pool = pool.get('hr.employee')
15 cr.execute("""
16@@ -116,6 +121,11 @@
17 employee_pool.write(
18 cr, 1, employee_id, {'department_id': row[1]})
19
20+ openupgrade.logged_query(cr, """
21+ UPDATE hr_employee
22+ SET parent_id = %s
23+ """ % openupgrade.get_legacy_name('parent_id'))
24+
25 def set_marital(cr, pool):
26 """
27 Migrate selection field 'marital' to
28
29=== modified file 'hr/migrations/6.0.1.1/pre-migration.py'
30--- hr/migrations/6.0.1.1/pre-migration.py 2012-06-07 14:51:52 +0000
31+++ hr/migrations/6.0.1.1/pre-migration.py 2012-07-19 10:47:55 +0000
32@@ -34,7 +34,7 @@
33 ('company_id', 'openupgrade_legacy_company_id'),
34 ('category_id', 'openupgrade_legacy_category_id'),
35 ('marital', 'openupgrade_legacy_marital'),
36- ('parent_id', 'openupgrade_legacy_parent_id'),
37+ ('parent_id', openupgrade.get_legacy_name('parent_id')),
38 ]
39 }
40
41
42=== modified file 'hr/migrations/6.0.1.1/user_notes.txt'
43--- hr/migrations/6.0.1.1/user_notes.txt 2012-05-21 15:35:12 +0000
44+++ hr/migrations/6.0.1.1/user_notes.txt 2012-07-19 10:47:55 +0000
45@@ -4,3 +4,5 @@
46 - An employee can now have multiple categories
47 - The employee model is integrated with the resource model
48 - Departments now have employees as their member type, not system users
49+
50+Note that in 6.0, the employee's manager is derived from the head of the department but the field is not actually written until you assign a new department to an employee in OpenERP 6.0. As in 6.1 this change is reverted, this migrationtakes care to preserve the users' managers. If you migrate from 5.0 to 6.1 without actually using the system in OpenERP 6.0, you will be able to keep the originally assigned managers on the employee records.

Subscribers

People subscribed via source and target branches