← Back to team overview

credativ team mailing list archive

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

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id into lp:openupgrade-addons/6.0.

Requested reviews:
  Don Kirkby (donkirkby)
  OpenUpgrade Committers (openupgrade-committers)
Related bugs:
  Bug #1023798 in OpenUpgrade Addons: "[6.0] hr_employee.parent_id should not be renamed"
  https://bugs.launchpad.net/openupgrade-addons/+bug/1023798

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id/+merge/115698

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).

-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id/+merge/115698
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.0-lp1023798-do_not_rename_hr_employee__parent_id into lp:openupgrade-addons/6.0.
=== modified file 'hr/migrations/6.0.1.1/post-migration.py'
--- hr/migrations/6.0.1.1/post-migration.py	2012-06-07 14:51:52 +0000
+++ hr/migrations/6.0.1.1/post-migration.py	2012-07-19 10:47:55 +0000
@@ -91,6 +91,11 @@
     to membership by employee. 
     In OpenERP 6, an employee can only be in a single
     department.
+
+    When the department is written on the employee record,
+    the manager is taken to be the head of the department in 6.0.
+    This change was reverted in 6.1. To accomodate migrations to 6.1,
+    restore the original manager 
     """
     employee_pool = pool.get('hr.employee')
     cr.execute("""
@@ -116,6 +121,11 @@
                 employee_pool.write(
                     cr, 1, employee_id, {'department_id': row[1]})
 
+    openupgrade.logged_query(cr, """
+        UPDATE hr_employee
+        SET parent_id = %s
+    """ % openupgrade.get_legacy_name('parent_id'))
+
 def set_marital(cr, pool):
     """
     Migrate selection field 'marital' to

=== modified file 'hr/migrations/6.0.1.1/pre-migration.py'
--- hr/migrations/6.0.1.1/pre-migration.py	2012-06-07 14:51:52 +0000
+++ hr/migrations/6.0.1.1/pre-migration.py	2012-07-19 10:47:55 +0000
@@ -34,7 +34,7 @@
         ('company_id', 'openupgrade_legacy_company_id'),
         ('category_id', 'openupgrade_legacy_category_id'),
         ('marital', 'openupgrade_legacy_marital'),
-        ('parent_id', 'openupgrade_legacy_parent_id'),
+        ('parent_id', openupgrade.get_legacy_name('parent_id')),
         ]
     }
 

=== modified file 'hr/migrations/6.0.1.1/user_notes.txt'
--- hr/migrations/6.0.1.1/user_notes.txt	2012-05-21 15:35:12 +0000
+++ hr/migrations/6.0.1.1/user_notes.txt	2012-07-19 10:47:55 +0000
@@ -4,3 +4,5 @@
 - An employee can now have multiple categories
 - The employee model is integrated with the resource model
 - Departments now have employees as their member type, not system users
+
+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.


Follow ups