Merge lp:~pedro.baeza/openupgrade-addons/7.0-project into lp:openupgrade-addons
- 7.0-project
- Merge into 7.0
Proposed by
Pedro Manuel Baeza
Status: | Merged |
---|---|
Merged at revision: | 8159 |
Proposed branch: | lp:~pedro.baeza/openupgrade-addons/7.0-project |
Merge into: | lp:openupgrade-addons |
Diff against target: |
284 lines (+265/-0) 4 files modified
project/migrations/7.0.1.1/openupgrade_analysis_work.txt (+144/-0) project/migrations/7.0.1.1/post-migration.py (+70/-0) project/migrations/7.0.1.1/pre-migration.py (+40/-0) project/migrations/7.0.1.1/user_notes.txt (+11/-0) |
To merge this branch: | bzr merge lp:~pedro.baeza/openupgrade-addons/7.0-project |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sandy Carter (http://www.savoirfairelinux.com) (community) | code review, no test | Approve | |
Holger Brunn (Therp) | Approve | ||
Review via email: mp+210214@code.launchpad.net |
Commit message
Description of the change
[ADD] project: Analysis work and migration scripts.
To post a comment you must log in.
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
PEP8
l.225 l.271
I would like to test this more in depth eventually.
review:
Needs Fixing
(code review, pep8)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Changes according your comments have been done.
Regards.
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) : | # |
review:
Approve
(code review, no test)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'project/migrations/7.0.1.1/openupgrade_analysis_work.txt' |
2 | --- project/migrations/7.0.1.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000 |
3 | +++ project/migrations/7.0.1.1/openupgrade_analysis_work.txt 2014-03-27 16:20:36 +0000 |
4 | @@ -0,0 +1,144 @@ |
5 | +---Fields in module 'project'--- |
6 | +project / account.analytic.account / use_tasks (boolean) : NEW |
7 | +### -> New field to indicate to use tasks in the project. It can be default to False. (Nothing to do) |
8 | + |
9 | +project / project.category / name (char) : NEW required: required |
10 | +project / project.task / categ_ids (many2many) : NEW relation: project.category |
11 | +### -> New complete model for categorizing tasks. It can be none category. (Nothing to do) |
12 | + |
13 | +project / project.project / state (selection) : NEW required: required, selection_keys: ['cancelled', 'close', 'draft', 'open', 'pending', 'template'], req_default: open |
14 | +### -> This state field has been moved from analytic account to the project. Done. |
15 | + |
16 | +project / project.task / stage_id (many2one) : NEW relation: project.task.type |
17 | +project / project.task / type_id (many2one) : DEL relation: project.task.type |
18 | +### -> Column rename. Done. |
19 | + |
20 | +project / project.task.type / case_default (boolean) : NEW |
21 | +project / project.task.type / project_default (boolean) : DEL |
22 | +### -> Column rename. Done. |
23 | + |
24 | +project / project.project / warn_customer (boolean) : DEL |
25 | +project / project.project / warn_footer (text) : DEL |
26 | +project / project.project / warn_header (text) : DEL |
27 | +project / project.project / warn_manager (boolean) : DEL |
28 | +### -> #TODO: Deleted fields, difficult to translate to the new system. Rarely used. |
29 | + |
30 | +project / project.task / state (selection) : now a function |
31 | +project / project.task.type / state (selection) : NEW required: required, selection_keys: ['cancelled', 'done', 'draft', 'open', 'pending'], req_default: open |
32 | +### -> #TODO: State field has been added on the stage, and state field in task is define as a function. |
33 | +### -> It can be queried previous state from tasks and deduced state value for the stage. |
34 | + |
35 | +project / project.project / alias_id (many2one) : NEW relation: mail.alias, required: required |
36 | +project / project.project / alias_model (selection) : NEW required: required, selection_keys: function, req_default: project.task |
37 | +### -> Alias for mail messages. Force creation on migration. Done. |
38 | + |
39 | +project / project.project / color (integer) : NEW |
40 | +### -> Optional field for color projects. (Nothing to do) |
41 | + |
42 | +project / project.project / privacy_visibility (selection): NEW required: required, selection_keys: ['followers', 'public'], req_default: public |
43 | +### -> New required field with default. (Nothing to do) |
44 | + |
45 | +project / project.task.history.cumulative / project_id (many2one) : not a function anymore |
46 | +### -> Now a related field. (Nothing to do) |
47 | + |
48 | +project / project.task.type / fold (boolean) : NEW |
49 | +### -> Optional field. Default to False is OK. (Nothing to do) |
50 | + |
51 | +project / report.project.task.user / type_id (many2one) : DEL relation: project.task.type |
52 | +### -> Removed field in a table view. (Nothing to do) |
53 | + |
54 | +project / res.users / context_project_id (many2one) : DEL relation: project.project |
55 | +### -> Useless field removed. (Nothing to do) |
56 | + |
57 | +---XML records in module 'project'--- |
58 | +NEW ir.actions.act_window: project.action_config_settings |
59 | +DEL ir.actions.act_window: project.act_my_account |
60 | +DEL ir.actions.act_window: project.act_my_project |
61 | +DEL ir.actions.act_window: project.act_res_users_2_project_project |
62 | +DEL ir.actions.act_window: project.action_create_initial_projects_installer |
63 | +DEL ir.actions.act_window: project.action_project_vs_remaining_hours_graph |
64 | +DEL ir.actions.act_window: project.action_review_task_stage |
65 | +DEL ir.actions.act_window: project.action_task_by_days_graph |
66 | +DEL ir.actions.act_window: project.action_view_delegate_task_tree |
67 | +DEL ir.actions.act_window: project.action_view_task_history_burndown |
68 | +DEL ir.actions.act_window: project.action_view_task_tree_deadline |
69 | +DEL ir.actions.act_window.view: project.open_view_project_vs_remaining_hours_graph |
70 | +DEL ir.actions.act_window.view: project.open_view_project_vs_remaining_hours_tree |
71 | +NEW ir.actions.client: project.action_client_project_menu |
72 | +### -> Deleted and added window and client actions. (Nothing to do) |
73 | + |
74 | +NEW ir.actions.todo: base.open_menu |
75 | +DEL ir.actions.todo: project.config_wizard_action_create_initial_projects_installer |
76 | +DEL ir.actions.todo: project.config_wizard_action_review_task_stage |
77 | +DEL ir.actions.todo.category: project.category_project_config |
78 | +### -> Changed configuration wizards. (Nothing to do) |
79 | + |
80 | +NEW ir.model.access: project.access_account_analytic_account_user |
81 | +NEW ir.model.access: project.access_project_category |
82 | +NEW ir.model.access: project.access_project_category_manager |
83 | +NEW ir.model.access: project.access_project_project_manager |
84 | +NEW ir.model.access: project.access_project_task_history_sale_user |
85 | +NEW ir.model.access: project.access_project_task_type_sale_user |
86 | +DEL ir.model.access: project.access_mail_message_project_user |
87 | +DEL ir.model.access: project.access_partner_address_task user |
88 | +DEL ir.model.access: project.access_project_vs_hours |
89 | +DEL ir.model.access: project.access_task_by_days |
90 | +NEW ir.rule: project.project_public_members_rule |
91 | +### -> Changed security rules. (Nothing to do) |
92 | + |
93 | +NEW ir.ui.menu: base.menu_definitions |
94 | +NEW ir.ui.menu: base.menu_project_config |
95 | +NEW ir.ui.menu: base.menu_project_config_project |
96 | +NEW ir.ui.menu: project.menu_project_dashboard |
97 | +NEW ir.ui.menu: project.menu_projects |
98 | +DEL ir.ui.menu: project.menu_action_view_task_history_burndown |
99 | +DEL ir.ui.menu: project.menu_board_project |
100 | +DEL ir.ui.menu: project.menu_definitions |
101 | +DEL ir.ui.menu: project.menu_open_view_project_all |
102 | +DEL ir.ui.menu: project.menu_project_config_project |
103 | +DEL ir.ui.menu: project.next_id_86 |
104 | +DEL ir.ui.menu: project.project_report_task |
105 | +### -> Changed menus. (Nothing to do) |
106 | + |
107 | +NEW ir.ui.view: project.analytic_account_inherited_form |
108 | +NEW ir.ui.view: project.view_config_settings |
109 | +NEW ir.ui.view: project.view_project_kanban |
110 | +DEL ir.ui.view: base.view_crm_partner_info_History |
111 | +DEL ir.ui.view: project.view_delegated_task_tree |
112 | +DEL ir.ui.view: project.view_project_users_form_simple |
113 | +DEL ir.ui.view: project.view_project_vs_planned_total_hours_graph |
114 | +DEL ir.ui.view: project.view_project_vs_planned_total_hours_tree |
115 | +DEL ir.ui.view: project.view_project_vs_remaining_hours_graph |
116 | +DEL ir.ui.view: project.view_project_vs_remaining_hours_tree |
117 | +DEL ir.ui.view: project.view_task_by_days_graph |
118 | +DEL ir.ui.view: project.view_task_by_days_tree |
119 | +DEL ir.ui.view: project.view_task_history_burndown_graph |
120 | +DEL ir.ui.view: project.view_users_form_project_modif_inherited1 |
121 | +### -> Changed views. (Nothing to do) |
122 | + |
123 | +NEW mail.message: project.module_install_notification |
124 | +NEW mail.message.subtype: project.mt_project_task_blocked |
125 | +NEW mail.message.subtype: project.mt_project_task_closed |
126 | +NEW mail.message.subtype: project.mt_project_task_new |
127 | +NEW mail.message.subtype: project.mt_project_task_stage |
128 | +NEW mail.message.subtype: project.mt_project_task_started |
129 | +NEW mail.message.subtype: project.mt_task_blocked |
130 | +NEW mail.message.subtype: project.mt_task_closed |
131 | +NEW mail.message.subtype: project.mt_task_new |
132 | +NEW mail.message.subtype: project.mt_task_stage |
133 | +NEW mail.message.subtype: project.mt_task_started |
134 | +### -> Chatter functions. (Nothing to do) |
135 | + |
136 | +NEW project.task.type: project.project_tt_analysis |
137 | +NEW project.task.type: project.project_tt_cancel |
138 | +NEW project.task.type: project.project_tt_deployment |
139 | +NEW project.task.type: project.project_tt_design |
140 | +### -> New task stages. (Nothing to do) |
141 | + |
142 | +NEW res.company: base.main_company |
143 | +### -> Company alias. (Nothing to do) |
144 | + |
145 | +NEW res.groups: project.group_delegate_task |
146 | +NEW res.groups: project.group_tasks_work_on_tasks |
147 | +NEW res.groups: project.group_time_work_estimation_tasks |
148 | +### -> New security groups. (Nothing to do) |
149 | |
150 | === added file 'project/migrations/7.0.1.1/post-migration.py' |
151 | --- project/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000 |
152 | +++ project/migrations/7.0.1.1/post-migration.py 2014-03-27 16:20:36 +0000 |
153 | @@ -0,0 +1,70 @@ |
154 | +# -*- coding: utf-8 -*- |
155 | +############################################################################## |
156 | +# |
157 | +# OpenERP, Open Source Management Solution |
158 | +# This migration script copyright (C) 2014 |
159 | +# Pedro M. Baeza (pedro.baeza@serviciosbaeza.com) |
160 | +# |
161 | +# This program is free software: you can redistribute it and/or modify |
162 | +# it under the terms of the GNU Affero General Public License as |
163 | +# published by the Free Software Foundation, either version 3 of the |
164 | +# License, or (at your option) any later version. |
165 | +# |
166 | +# This program is distributed in the hope that it will be useful, |
167 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
168 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
169 | +# GNU Affero General Public License for more details. |
170 | +# |
171 | +# You should have received a copy of the GNU Affero General Public License |
172 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
173 | +# |
174 | +############################################################################## |
175 | +from openupgrade import openupgrade |
176 | +from openerp import pooler, SUPERUSER_ID |
177 | + |
178 | +def copy_state_from_analytic_account(cr): |
179 | + openupgrade.logged_query(cr, """ |
180 | + UPDATE project_project |
181 | + SET state = account_analytic_account.%s |
182 | + FROM project_project |
183 | + INNER JOIN account_analytic_account |
184 | + ON account_analytic_account.id = project_project.analytic_account_id |
185 | + WHERE analytic_account_id is not NULL |
186 | + """ %(openupgrade.get_legacy_name('state'))) |
187 | + |
188 | +def short_name(name): |
189 | + """Keep first word(s) of name to make it small enough |
190 | + but distinctive""" |
191 | + if not name: return name |
192 | + # keep 7 chars + end of the last word |
193 | + keep_words = name[:7].strip().split() |
194 | + return ' '.join(name.split()[:len(keep_words)]) |
195 | + |
196 | +def createProjectAliases(cr, pool): |
197 | + alias_obj = pool.get('mail.alias') |
198 | + project_obj = pool.get('project.project') |
199 | + cr.execute(""" |
200 | + SELECT project_project.id, account_analytic_account.name |
201 | + FROM project_project, account_analytic_account |
202 | + WHERE account_analytic_account.name is not NULL |
203 | + AND project_project.alias_id is NULL |
204 | + AND project_project.analytic_account_id = account_analytic_account.id |
205 | + """) |
206 | + for (id, name) in cr.fetchall(): |
207 | + alias_id = alias_obj.create_unique_alias(cr, SUPERUSER_ID, |
208 | + {'alias_name': "project+" + short_name(name)}, |
209 | + model_name='project.task') |
210 | + cr.execute(""" |
211 | + UPDATE project_project |
212 | + SET alias_id=%s |
213 | + WHERE id=%s |
214 | + """, (alias_id, id)) |
215 | + |
216 | +@openupgrade.migrate() |
217 | +def migrate(cr, version): |
218 | + if not version: |
219 | + return |
220 | + pool = pooler.get_pool(cr.dbname) |
221 | + copy_state_from_analytic_account(cr) |
222 | + createProjectAliases(cr, pool) |
223 | + openupgrade.logged_query(cr,'DROP VIEW project_vs_hours') |
224 | |
225 | === added file 'project/migrations/7.0.1.1/pre-migration.py' |
226 | --- project/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000 |
227 | +++ project/migrations/7.0.1.1/pre-migration.py 2014-03-27 16:20:36 +0000 |
228 | @@ -0,0 +1,40 @@ |
229 | +# -*- coding: utf-8 -*- |
230 | +############################################################################## |
231 | +# |
232 | +# OpenERP, Open Source Management Solution |
233 | +# This migration script copyright (C) 2014 |
234 | +# Pedro M. Baeza (pedro.baeza@serviciosbaeza.com) |
235 | +# |
236 | +# This program is free software: you can redistribute it and/or modify |
237 | +# it under the terms of the GNU Affero General Public License as |
238 | +# published by the Free Software Foundation, either version 3 of the |
239 | +# License, or (at your option) any later version. |
240 | +# |
241 | +# This program is distributed in the hope that it will be useful, |
242 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
243 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
244 | +# GNU Affero General Public License for more details. |
245 | +# |
246 | +# You should have received a copy of the GNU Affero General Public License |
247 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
248 | +# |
249 | +############################################################################## |
250 | +from openupgrade import openupgrade |
251 | + |
252 | +column_renames = { |
253 | + 'account_analytic_account':[ |
254 | + ('state', None), |
255 | + ], |
256 | + 'project_task':[ |
257 | + ('type_id', 'stage_id'), |
258 | + ], |
259 | + 'project_task_type':[ |
260 | + ('project_default', 'case_default'), |
261 | + ], |
262 | +} |
263 | + |
264 | +@openupgrade.migrate() |
265 | +def migrate(cr, version): |
266 | + if not version: |
267 | + return |
268 | + openupgrade.rename_columns(cr, column_renames) |
269 | |
270 | === added file 'project/migrations/7.0.1.1/user_notes.txt' |
271 | --- project/migrations/7.0.1.1/user_notes.txt 1970-01-01 00:00:00 +0000 |
272 | +++ project/migrations/7.0.1.1/user_notes.txt 2014-03-27 16:20:36 +0000 |
273 | @@ -0,0 +1,11 @@ |
274 | +******************************************************************************** |
275 | +1/ If you have defined custom project stages (project.task.type), related state |
276 | +will be set default to open, and related task will have this state. If you |
277 | +want to set them to another state, you will have to do it manually. |
278 | + |
279 | +2/ Project warning messages when you close tasks are lost in the migration, |
280 | +because they are not easily translated to the new system, so you will have to |
281 | +rewrite them on v7. |
282 | + |
283 | +3/ All projects are set by default to public visibility. Change manually |
284 | +on each project accordingly new possibilities and your needs. |
Concerning warn_*: I'd say that should be managed by subscriptions now?
#179 are you aware of postgres' update from construction? That would save you the subquery here: analytic_ account where account_ analytic_ account. id = project_ project. analytic_ account_ id
update project_project set state=%s from account_