Merge lp:~sylvain-legal/openupgrade-addons/7.0-hr into lp:openupgrade-addons

Proposed by Sylvain LE GAL (GRAP)
Status: Merged
Merged at revision: 8141
Proposed branch: lp:~sylvain-legal/openupgrade-addons/7.0-hr
Merge into: lp:openupgrade-addons
Diff against target: 182 lines (+168/-0)
3 files modified
hr/migrations/7.0.1.1/openupgrade_analysis_work.txt (+64/-0)
hr/migrations/7.0.1.1/post-migration.py (+70/-0)
hr/migrations/7.0.1.1/pre-migration.py (+34/-0)
To merge this branch: bzr merge lp:~sylvain-legal/openupgrade-addons/7.0-hr
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+186380@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! Looks good to me.

review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'hr/migrations/7.0.1.1/openupgrade_analysis_work.txt'
2--- hr/migrations/7.0.1.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000
3+++ hr/migrations/7.0.1.1/openupgrade_analysis_work.txt 2013-09-18 16:11:42 +0000
4@@ -0,0 +1,64 @@
5+---Fields in module 'hr'---
6+# Migration script will use 'set_partner_id_from_partner_address_id' to change model. OK.
7+hr / hr.employee / address_home_id (many2one) : relation is now 'res.partner' ('res.partner.address')
8+
9+# Migration script will use 'set_partner_id_from_partner_address_id' to change model. OK.
10+hr / hr.employee / address_id (many2one) : relation is now 'res.partner' ('res.partner.address')
11+
12+### in 'hr.employee' model, 'photo' has been renamed in 'image'. OK.
13+hr / hr.employee / photo (binary) : DEL
14+hr / hr.employee / image (binary) : NEW
15+
16+### Ignore, no existing data to push as messages
17+hr / hr.job / message_ids (one2many) : NEW relation: mail.message
18+
19+### Change in keys :
20+# DEL KEYS : ('old').
21+# Script migration will change 'old' state in 'open' state.
22+# There is no problem, because there isn't workflow associated. OK.
23+hr / hr.job / state (selection) : selection_keys is now '['open', 'recruit']' ('['old', 'open', 'recruit']')
24+
25+
26+# In 6.1, hr.department was in res.users and hr_employee.
27+# In 7.0, there isn't relation between res.users and hr.department.
28+# Migration choice : we'll put in hr_employee they don't have hr_department, the department of the associated user. (if any) OK.
29+hr / res.users / context_department_id (many2one): DEL relation: hr.department
30+
31+### New one2many fields in 'res.users' model. Nothing to do.
32+hr / res.users / employee_ids (one2many) : NEW relation: hr.employee
33+
34+
35+---XML records in module 'hr'---
36+### Ignore interface and access records
37+NEW ir.actions.act_window: hr.action_human_resources_configuration
38+NEW ir.actions.act_window: hr.open_payroll_modules
39+DEL ir.actions.act_window: hr.action_create_hr_employee_installer
40+DEL ir.actions.act_window: hr.open_board_hr_manager
41+DEL ir.actions.act_window: hr.open_view_categ_tree
42+DEL ir.actions.act_window.view: hr.open_view_employee_list_my_form2
43+DEL ir.actions.act_window.view: hr.open_view_employee_list_my_kanban
44+DEL ir.actions.act_window.view: hr.open_view_employee_list_my_tree2
45+NEW ir.actions.client: hr.action_client_hr_menu
46+NEW ir.actions.todo: base.open_menu
47+DEL ir.actions.todo: hr.config_wizard_action_create_hr_employee_installer
48+DEL ir.actions.todo: hr.view_department_form_todo
49+DEL ir.actions.todo.category: hr.category_hr_management_config
50+DEL ir.model.access: hr.access_hr_res_partner_address
51+NEW ir.ui.menu: hr.menu_hr_reporting_timesheet
52+NEW ir.ui.menu: hr.menu_human_resources_configuration
53+DEL ir.ui.menu: hr.menu_hr_dashboard_manager
54+DEL ir.ui.menu: hr.menu_hr_dashboard_user
55+DEL ir.ui.menu: hr.menu_hr_management
56+DEL ir.ui.menu: hr.menu_view_employee_category_configuration_form
57+DEL ir.ui.menu: hr.menu_view_employee_category_tree
58+NEW ir.ui.view: hr.view_hr_job_employee_form
59+NEW ir.ui.view: hr.view_human_resources_configuration
60+DEL ir.ui.view: hr.board_hr_manager_form
61+DEL ir.ui.view: hr.view_department_form_simple_modif_inherited1
62+DEL ir.ui.view: hr.view_users_form_inherit
63+
64+### Ignore added chatter configuration
65+NEW mail.message: hr.module_install_notification
66+
67+### Ignore new groups configuration
68+NEW res.groups: base.group_user
69
70=== added file 'hr/migrations/7.0.1.1/post-migration.py'
71--- hr/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
72+++ hr/migrations/7.0.1.1/post-migration.py 2013-09-18 16:11:42 +0000
73@@ -0,0 +1,70 @@
74+# -*- coding: utf-8 -*-
75+##############################################################################
76+#
77+# OpenERP, Open Source Management Solution
78+# This module copyright (C) 2013 Sylvain LE GAL
79+#
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU Affero General Public License as
82+# published by the Free Software Foundation, either version 3 of the
83+# License, or (at your option) any later version.
84+#
85+# This program is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU Affero General Public License for more details.
89+#
90+# You should have received a copy of the GNU Affero General Public License
91+# along with this program. If not, see <http://www.gnu.org/licenses/>.
92+#
93+##############################################################################
94+
95+from openupgrade import openupgrade, openupgrade_70
96+from openerp import pooler, SUPERUSER_ID
97+
98+def migrate_hr_employee_addresses(cr, pool):
99+ """
100+ Change reference to old res_partner_address to new res_partner
101+ """
102+ # 'address_home_id' is now a 'res.partner' object
103+ openupgrade_70.set_partner_id_from_partner_address_id(
104+ cr, pool, 'hr.employee',
105+ 'address_home_id', openupgrade.get_legacy_name('address_home_id'))
106+ # 'address_id' is now a 'res.partner' object
107+ openupgrade_70.set_partner_id_from_partner_address_id(
108+ cr, pool, 'hr.employee',
109+ 'address_id', openupgrade.get_legacy_name('address_id'))
110+
111+def migrate_hr_employee_department(cr, pool):
112+ """
113+ Update 'hr_employee.department_id' with value from deleted res_users.context_department_id.
114+ """
115+ hr_employee_obj = pool.get('hr.employee')
116+ cr.execute("""
117+ SELECT
118+ hr_emp.id as hr_emp_id,
119+ res_users.context_department_id as dep_id
120+ FROM hr_employee hr_emp
121+ INNER JOIN resource_resource res_res ON hr_emp.resource_id = res_res.id
122+ INNER JOIN res_users ON res_res.user_id = res_users.id
123+ WHERE hr_emp.department_id is null
124+ AND NOT res_users.context_department_id is null""")
125+ for (hr_emp_id, dep_id) in cr.fetchall():
126+ vals = {
127+ 'department_id': dep_id,
128+ }
129+ hr_employee_obj.write(cr, SUPERUSER_ID, hr_emp_id, vals)
130+
131+def migrate_hr_job(cr):
132+ """
133+ Change obsolete selection values for hr_job.state
134+ """
135+ openupgrade.logged_query(
136+ cr, "UPDATE hr_job SET state = 'open' WHERE state = 'old' ")
137+
138+@openupgrade.migrate()
139+def migrate(cr, version):
140+ pool = pooler.get_pool(cr.dbname)
141+ migrate_hr_employee_addresses(cr, pool)
142+ migrate_hr_employee_department(cr, pool)
143+ migrate_hr_job(cr)
144
145=== added file 'hr/migrations/7.0.1.1/pre-migration.py'
146--- hr/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
147+++ hr/migrations/7.0.1.1/pre-migration.py 2013-09-18 16:11:42 +0000
148@@ -0,0 +1,34 @@
149+# -*- coding: utf-8 -*-
150+##############################################################################
151+#
152+# OpenERP, Open Source Management Solution
153+# This module copyright (C) 2013 Sylvain LE GAL
154+#
155+# This program is free software: you can redistribute it and/or modify
156+# it under the terms of the GNU Affero General Public License as
157+# published by the Free Software Foundation, either version 3 of the
158+# License, or (at your option) any later version.
159+#
160+# This program is distributed in the hope that it will be useful,
161+# but WITHOUT ANY WARRANTY; without even the implied warranty of
162+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
163+# GNU Affero General Public License for more details.
164+#
165+# You should have received a copy of the GNU Affero General Public License
166+# along with this program. If not, see <http://www.gnu.org/licenses/>.
167+#
168+##############################################################################
169+
170+from openupgrade import openupgrade
171+
172+column_renames = {
173+ 'hr_employee': [
174+ ('address_home_id', None),
175+ ('address_id', None),
176+ ('photo', 'image'),
177+ ]
178+}
179+
180+@openupgrade.migrate()
181+def migrate(cr, version):
182+ openupgrade.rename_columns(cr, column_renames)

Subscribers

People subscribed via source and target branches