← Back to team overview

credativ team mailing list archive

[Merge] lp:~therp-nl/openupgrade-addons/6.1-hr into lp:openupgrade-addons

 

Holger Brunn (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.1-hr into lp:openupgrade-addons.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-hr/+merge/109608
-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-hr/+merge/109608
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.1-hr into lp:openupgrade-addons.
=== modified file 'hr/migrations/6.1.1.1/post-migration.py'
--- hr/migrations/6.1.1.1/post-migration.py	2012-06-08 09:18:00 +0000
+++ hr/migrations/6.1.1.1/post-migration.py	2012-06-11 11:05:27 +0000
@@ -8,30 +8,65 @@
 @openupgrade.migrate()
 def migrate(cr, version):
     pool = pooler.get_pool(cr.dbname)
-    #null values of the many2one are reset to first value in the selection, restore the null values
-    cr.execute('update hr_employee set marital=NULL where openupgrade_legacy_marital is NULL')
-    #get possible marital states and if in the original many2one, update selection field
+    #null values of the many2one are reset to first value in the selection, 
+    #restore the null values
+    cr.execute('update hr_employee set marital=NULL where '+
+        openupgrade.get_legacy_name('marital', version)+' is NULL')
+    #get possible marital states and if in the original many2one, update 
+    #selection field
     marital_states={}
-    for (marital_state,marital_state_name)  in pool.get('hr.employee')._columns['marital'].selection:
+    for (marital_state,marital_state_name) in pool.get('hr.employee')._columns['marital'].selection:
         cr.execute(
-                'update hr_employee set marital=%(marital_state)s where openupgrade_legacy_marital in'+
-                '(select id from openupgrade_legacy_hr_employee_marital_status where lower(name) in %(marital_states)s)',
-                {'marital_state': marital_state, 'marital_states': tuple([marital_state.lower(),marital_state_name.lower()])})
+            'update hr_employee set marital=%(marital_state)s where '+
+            openupgrade.get_legacy_name('marital', version)+' in'+
+            '(select id from '+
+            openupgrade.get_legacy_name('hr_employee_marital_status', version)+
+            ' where lower(name) in %(marital_states)s)',            
+            {
+                'marital_state': marital_state, 
+                'marital_states': 
+                    tuple([marital_state.lower(),marital_state_name.lower()])
+            })
         marital_states[marital_state]=marital_state_name
         
     #get marital states not included in the selection
-    cr.execute('select id from hr_employee where openupgrade_legacy_marital is not null and openupgrade_legacy_marital not in '+
-            '(select id from openupgrade_legacy_hr_employee_marital_status where lower(name) in %(marital_states)s)',
-            {'marital_states': tuple([v.lower() for v in marital_states.itervalues()]+[k.lower() for k in marital_states.iterkeys()])})
+    cr.execute(
+        'select id from hr_employee where '+
+        openupgrade.get_legacy_name('marital', version)+' is not null and '+
+        openupgrade.get_legacy_name('marital', version)+' not in '+
+        '(select id from '+
+            openupgrade.get_legacy_name('hr_employee_marital_status', version)+
+            ' where lower(name) in %(marital_states)s)',
+        {
+            'marital_states': 
+                tuple(
+                    [v.lower() for v in marital_states.itervalues()]+
+                    [k.lower() for k in marital_states.iterkeys()])
+        })
     if cr.rowcount:
-        logger.warning('not all values of hr_employee_marital_status are in the selection. review hr_employee ids %s', [row[0] for row in cr.fetchall()])
+        logger.warning('not all values of hr_employee_marital_status are in '+
+            'the selection. review hr_employee ids %s', 
+            [row[0] for row in cr.fetchall()])
     else:
         logger.info('all values of hr_employee_marital_status are in the selection')
-        openupgrade.drop_columns(cr, [('hr_employee', 'openupgrade_legacy_marital')])
-        cr.execute('drop table openupgrade_legacy_hr_employee_marital_status')
+        openupgrade.drop_columns(
+            cr, 
+            [('hr_employee', 
+                openupgrade.get_legacy_name('marital', version))])
+        cr.execute('drop table '+
+            openupgrade.get_legacy_name('hr_employee_marital_status', version))
 
     #fields have been calculated already
-    cr.execute('update hr_job set no_of_recruitment=openupgrade_legacy_expected_employees-no_of_employee')
+    cr.execute(
+        'update hr_job set no_of_recruitment='+
+        openupgrade.get_legacy_name('expected_employees', version)+
+        '-no_of_employee')
     #recalculate expectred employees
-    cr.execute('update hr_job set expected_employees=no_of_recruitment+no_of_employee')
-    openupgrade.drop_columns(cr, [('hr_job', 'openupgrade_legacy_expected_employees')])
+    cr.execute(
+        'update hr_job set expected_employees=no_of_recruitment+no_of_employee')
+    openupgrade.drop_columns(
+            cr, 
+            [(
+                'hr_job', 
+                openupgrade.get_legacy_name('expected_employees', version)
+            )])

=== modified file 'hr/migrations/6.1.1.1/pre-migration.py'
--- hr/migrations/6.1.1.1/pre-migration.py	2012-06-07 13:13:15 +0000
+++ hr/migrations/6.1.1.1/pre-migration.py	2012-06-11 11:05:27 +0000
@@ -4,15 +4,15 @@
 
 @openupgrade.migrate()
 def migrate(cr, version):
-    openupgrade.rename_tables(cr, [('hr_employee_marital_status', 'openupgrade_legacy_hr_employee_marital_status')])
+    openupgrade.rename_tables(cr, [('hr_employee_marital_status', openupgrade.get_legacy_name('hr_employee_marital_status', version))])
     openupgrade.rename_columns(cr, 
             {
                 'hr_employee': 
                 [
-                    ('marital', 'openupgrade_legacy_marital'), 
+                    ('marital', openupgrade.get_legacy_name('marital', version)), 
                 ],
                 'hr_job': 
                 [
-                    ('expected_employees', 'openupgrade_legacy_expected_employees')
+                    ('expected_employees', openupgrade.get_legacy_name('expected_employees', version))
                 ],
             })

=== modified file 'hr/migrations/6.1.1.1/user_notes.txt'
--- hr/migrations/6.1.1.1/user_notes.txt	2012-06-08 13:03:40 +0000
+++ hr/migrations/6.1.1.1/user_notes.txt	2012-06-11 11:05:27 +0000
@@ -1,2 +1,2 @@
-Marital status has been changed (back) to be a selection. The script tries to find a suitable selection entry from the list of marital states. This will fail if you customized this list, you'll get a warning about the employee IDs with marital states not in the selection, and find the original values in column openupgrade_legacy_marital. If you customize the selection *before* the migration with the same values used in the list of martial states, this script will pick up those values too.
+Marital status has been changed (back) to be a selection. The script tries to find a suitable selection entry from the list of marital states. This will fail if you customized this list, you'll get a warning about the employee IDs with marital states not in the selection, and find the original values in column openupgrade_6_1_1_1_legacy_marital. If you customize the selection *before* the migration with the same values used in the list of martial states, this script will pick up those values too.
 If there are no unknown marital states (either because you didn't customize them or you put your customizations into the selection), the legacy column and the table will be dropped after migration.