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

Proposed by Holger Brunn (Therp)
Status: Superseded
Proposed branch: lp:~therp-nl/openupgrade-addons/6.1-hr
Merge into: lp:openupgrade-addons/6.1
Diff against target: 116 lines (+55/-20)
3 files modified
hr/migrations/6.1.1.1/post-migration.py (+51/-16)
hr/migrations/6.1.1.1/pre-migration.py (+3/-3)
hr/migrations/6.1.1.1/user_notes.txt (+1/-1)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.1-hr
Reviewer Review Type Date Requested Status
OpenUpgrade Committers Pending
Review via email: mp+109608@code.launchpad.net

This proposal has been superseded by a proposal from 2012-06-11.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr/migrations/6.1.1.1/post-migration.py'
2--- hr/migrations/6.1.1.1/post-migration.py 2012-06-08 09:18:00 +0000
3+++ hr/migrations/6.1.1.1/post-migration.py 2012-06-11 14:26:22 +0000
4@@ -8,30 +8,65 @@
5 @openupgrade.migrate()
6 def migrate(cr, version):
7 pool = pooler.get_pool(cr.dbname)
8- #null values of the many2one are reset to first value in the selection, restore the null values
9- cr.execute('update hr_employee set marital=NULL where openupgrade_legacy_marital is NULL')
10- #get possible marital states and if in the original many2one, update selection field
11+ #null values of the many2one are reset to first value in the selection,
12+ #restore the null values
13+ cr.execute('update hr_employee set marital=NULL where '+
14+ openupgrade.get_legacy_name('marital')+' is NULL')
15+ #get possible marital states and if in the original many2one, update
16+ #selection field
17 marital_states={}
18- for (marital_state,marital_state_name) in pool.get('hr.employee')._columns['marital'].selection:
19+ for (marital_state,marital_state_name) in pool.get('hr.employee')._columns['marital'].selection:
20 cr.execute(
21- 'update hr_employee set marital=%(marital_state)s where openupgrade_legacy_marital in'+
22- '(select id from openupgrade_legacy_hr_employee_marital_status where lower(name) in %(marital_states)s)',
23- {'marital_state': marital_state, 'marital_states': tuple([marital_state.lower(),marital_state_name.lower()])})
24+ 'update hr_employee set marital=%(marital_state)s where '+
25+ openupgrade.get_legacy_name('marital')+' in'+
26+ '(select id from '+
27+ openupgrade.get_legacy_name('hr_employee_marital_status')+
28+ ' where lower(name) in %(marital_states)s)',
29+ {
30+ 'marital_state': marital_state,
31+ 'marital_states':
32+ tuple([marital_state.lower(),marital_state_name.lower()])
33+ })
34 marital_states[marital_state]=marital_state_name
35
36 #get marital states not included in the selection
37- cr.execute('select id from hr_employee where openupgrade_legacy_marital is not null and openupgrade_legacy_marital not in '+
38- '(select id from openupgrade_legacy_hr_employee_marital_status where lower(name) in %(marital_states)s)',
39- {'marital_states': tuple([v.lower() for v in marital_states.itervalues()]+[k.lower() for k in marital_states.iterkeys()])})
40+ cr.execute(
41+ 'select id from hr_employee where '+
42+ openupgrade.get_legacy_name('marital')+' is not null and '+
43+ openupgrade.get_legacy_name('marital')+' not in '+
44+ '(select id from '+
45+ openupgrade.get_legacy_name('hr_employee_marital_status')+
46+ ' where lower(name) in %(marital_states)s)',
47+ {
48+ 'marital_states':
49+ tuple(
50+ [v.lower() for v in marital_states.itervalues()]+
51+ [k.lower() for k in marital_states.iterkeys()])
52+ })
53 if cr.rowcount:
54- 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()])
55+ logger.warning('not all values of hr_employee_marital_status are in '+
56+ 'the selection. review hr_employee ids %s',
57+ [row[0] for row in cr.fetchall()])
58 else:
59 logger.info('all values of hr_employee_marital_status are in the selection')
60- openupgrade.drop_columns(cr, [('hr_employee', 'openupgrade_legacy_marital')])
61- cr.execute('drop table openupgrade_legacy_hr_employee_marital_status')
62+ openupgrade.drop_columns(
63+ cr,
64+ [('hr_employee',
65+ openupgrade.get_legacy_name('marital'))])
66+ cr.execute('drop table '+
67+ openupgrade.get_legacy_name('hr_employee_marital_status'))
68
69 #fields have been calculated already
70- cr.execute('update hr_job set no_of_recruitment=openupgrade_legacy_expected_employees-no_of_employee')
71+ cr.execute(
72+ 'update hr_job set no_of_recruitment='+
73+ openupgrade.get_legacy_name('expected_employees')+
74+ '-no_of_employee')
75 #recalculate expectred employees
76- cr.execute('update hr_job set expected_employees=no_of_recruitment+no_of_employee')
77- openupgrade.drop_columns(cr, [('hr_job', 'openupgrade_legacy_expected_employees')])
78+ cr.execute(
79+ 'update hr_job set expected_employees=no_of_recruitment+no_of_employee')
80+ openupgrade.drop_columns(
81+ cr,
82+ [(
83+ 'hr_job',
84+ openupgrade.get_legacy_name('expected_employees')
85+ )])
86
87=== modified file 'hr/migrations/6.1.1.1/pre-migration.py'
88--- hr/migrations/6.1.1.1/pre-migration.py 2012-06-07 13:13:15 +0000
89+++ hr/migrations/6.1.1.1/pre-migration.py 2012-06-11 14:26:22 +0000
90@@ -4,15 +4,15 @@
91
92 @openupgrade.migrate()
93 def migrate(cr, version):
94- openupgrade.rename_tables(cr, [('hr_employee_marital_status', 'openupgrade_legacy_hr_employee_marital_status')])
95+ openupgrade.rename_tables(cr, [('hr_employee_marital_status', openupgrade.get_legacy_name('hr_employee_marital_status'))])
96 openupgrade.rename_columns(cr,
97 {
98 'hr_employee':
99 [
100- ('marital', 'openupgrade_legacy_marital'),
101+ ('marital', openupgrade.get_legacy_name('marital')),
102 ],
103 'hr_job':
104 [
105- ('expected_employees', 'openupgrade_legacy_expected_employees')
106+ ('expected_employees', openupgrade.get_legacy_name('expected_employees'))
107 ],
108 })
109
110=== modified file 'hr/migrations/6.1.1.1/user_notes.txt'
111--- hr/migrations/6.1.1.1/user_notes.txt 2012-06-08 13:03:40 +0000
112+++ hr/migrations/6.1.1.1/user_notes.txt 2012-06-11 14:26:22 +0000
113@@ -1,2 +1,2 @@
114-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.
115+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.
116 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.

Subscribers

People subscribed via source and target branches