Merge lp:~akretion-team/openupgrade-addons/61-to-70-document into lp:openupgrade-addons
- 61-to-70-document
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 8171 |
Proposed branch: | lp:~akretion-team/openupgrade-addons/61-to-70-document |
Merge into: | lp:openupgrade-addons |
Diff against target: |
199 lines (+185/-0) 3 files modified
document/migrations/7.0.2.1/openupgrade_analysis_work.txt (+72/-0) document/migrations/7.0.2.1/post-migration.py (+76/-0) document/migrations/7.0.2.1/pre-migration.py (+37/-0) |
To merge this branch: | bzr merge lp:~akretion-team/openupgrade-addons/61-to-70-document |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Holger Brunn (Therp) | Approve | ||
Sylvain LE GAL (GRAP) | code review, no test. | Needs Information | |
Pedro Manuel Baeza | code review | Approve | |
Review via email: mp+221970@code.launchpad.net |
Commit message
Description of the change
Document module : add migration scripts for 6.1 -> 7.0 migration
Alexis de Lattre (alexis-via) wrote : | # |
Yann Papouin (yann-papouin) wrote : | # |
The same two or three times, I had to delete my branch from launchpad and re-push it from my local repo.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Alexis,
In a first sight, pre-migration.py doesn't do anything. You need to add this code:
@openupgrade.
def migrate(cr, version):
openupgrade
But I don't see then what do you do with renamed columns to None on post script. Can you enligthened me?
Regards.
Alexis de Lattre (alexis-via) wrote : | # |
@Pedro
You are right, I declared the rename_columns, and I forgot to use it in the post-migration... but it was working ! For a strange reason, the columns of the document_storage were kept during the upgrade.
But Sylvain convinced me of updating my code, so I updated the code to use the rename_columns :)
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Although this migration in most cases will require manual intervertion afterwards, it's the most conservative. Or what do you think about move files at OS level to a fixed path and configure ir.parameter to this fixed path. In this way, we are getting the desired goal of OpenUpgrade to do it all by itself. What do you think about this?
Regards.
Alexis de Lattre (alexis-via) wrote : | # |
@Pedro
I don't have enough experience on OpenUpgrade to have an opinion on this. This is a question for Stefan or Sylvain I think...
But moving files at OS level requires write permission on the destination directory (and may also require to create the destination directory), and the user who execute the OpenERP server for openupgrade may not have the required permissions.
Also, if we move files to a new directory and this directory is on another partition, we should make sure that there is enough space on the destination partition. All these files may weight several GB...
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Yeah, you're right about some considerations. I think write condition can be a must for this, or show a warning about that. Another option can be to make a symbolic link (only for Linux and Windows), and in this way, you don't need to check disk space.
Let's involve as you say another people like Stefan or Sylvain to say their opinion.
Regards.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
s/Windows/MacOS
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
Hi,
I don't use storage by filesystem for own database for the moment. So I didn't have the problem when I realized my 5.0 -> 6.1 migration and 6.1 -> 7.0.
However, I think that moving files will not work in many cases. As said, depending of OS, space on disk, access right, but mainly because in some cases OpenUpgrade Server is not the production server for some reasons:
1/ You don't have access to the server: Your customer manage his server and send you his database (anonymized or not) to migrate it. (As OpenERP S.A. does)
2/ You have access to the server but prefer to run openupgrade locally or on another server for some reasons.(to do tests, to avoid to install OpenUpgrade on the server because it is a non-production server, etc...)
So The only thing that will allways work is to put a warning in OpenUpgrade log file for the user that upgrade the system.
Regards.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
As you both pointed out, there are many restrictions in the move operation, so let's stay as is with the warning.
Regards.
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
Just one thing. If you do not manage the case of the xml_id "dir_partner_
Why do you guess that this object is unused ?
What about to do in a pre-migration script a request like the following, to make the object persistent ?
delete * from ir_model_data where module ='document' and name ='dir_partner_
Otherwise, all looks good to me.
Holger Brunn (Therp) (hbrunn) wrote : | # |
Just for completeness: NTFS (Windows' filesystem) support hard and soft links for years, it's just that there's no default UI for that...
I agree with not touching the files, there's a lot of uncertainties here and the danger to screw up is very high.
Preview Diff
1 | === added file 'document/migrations/7.0.2.1/openupgrade_analysis_work.txt' |
2 | --- document/migrations/7.0.2.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000 |
3 | +++ document/migrations/7.0.2.1/openupgrade_analysis_work.txt 2014-06-04 22:01:29 +0000 |
4 | @@ -0,0 +1,72 @@ |
5 | +---Fields in module 'document'--- |
6 | +# IMPORTANT NOTE : due to a bug in OpenUpgrade |
7 | +# (cf https://github.com/OpenUpgrade/OpenUpgrade/issues/40) |
8 | +# one important thing is missing in this analysis file : |
9 | +# the table document_storage as been dropped ! |
10 | +# If you have some storage of type "filestore", openupgrade will add |
11 | +# an entry in ir.config_parameter like this one : |
12 | +# {key: ir_attachment.location, value: file:///filestore} |
13 | + |
14 | +# Document.storage has been dropped in v7, so the M2O links to document.storage is removed => nothing to do |
15 | +document / document.directory / storage_id (many2one) : DEL relation: document.storage |
16 | + |
17 | +# These fields are moved to a lower-level module (base), so there is nothing to do. |
18 | +document / ir.attachment / db_datas (binary) : module is now 'base' ('document') |
19 | +document / ir.attachment / file_size (integer) : module is now 'base' ('document') |
20 | +# Note : the size of this char field move upgraded from 200 to 256 |
21 | +document / ir.attachment / store_fname (char) : module is now 'base' ('document') |
22 | + |
23 | +# In all my 6.1 production databases, this field is always empty... |
24 | +# Looking at the code of the document module in 6.1, it seems that this field |
25 | +# was not used |
26 | +document / process.node / directory_id (many2one) : DEL relation: document.directory |
27 | + |
28 | +# report.document.user is _auto = False (SQL view) => nothing to do |
29 | +document / report.document.user / user (char) : now a function |
30 | + |
31 | +---XML records in module 'document'--- |
32 | + |
33 | +# This record is not provided by default any more, but I think that nobody uses this |
34 | +DEL document.directory: document.dir_partner_category |
35 | + |
36 | +# Document.storage has been dropped in v7 |
37 | +DEL document.storage: document.storage_default |
38 | + |
39 | +NEW ir.actions.act_window: document.action_view_files_by_user_graph |
40 | +DEL ir.actions.act_window: document.action_document_storage_form |
41 | +DEL ir.actions.act_window: document.action_view_files_by_partner |
42 | +DEL ir.actions.act_window: document.action_view_user_graph |
43 | +DEL ir.actions.act_window: document.action_view_wall |
44 | +DEL ir.actions.act_window: document.open_board_document_manager |
45 | +DEL ir.actions.act_window: document.open_board_document_manager1 |
46 | +DEL ir.actions.todo.category: document.category_knowledge_mgmt_config |
47 | +DEL ir.model.access: document.access_document_storage_group_document_manager |
48 | +DEL ir.model.access: document.access_document_storage_group_system |
49 | +DEL ir.model.access: document.access_document_storage_group_user |
50 | +DEL ir.model.access: document.access_report_document_wall_group_document |
51 | +DEL ir.model.access: document.access_report_document_wall_group_document_manager |
52 | +DEL ir.model.access: document.access_report_document_wall_group_system |
53 | +DEL ir.model.access: document.access_report_files_partner_group_document |
54 | +DEL ir.model.access: document.access_report_files_partner_group_document_manager |
55 | +DEL ir.ui.menu: document.menu_document_storage_media |
56 | +DEL ir.ui.menu: document.menu_reporting |
57 | +DEL ir.ui.menu: document.menu_reports_document |
58 | +DEL ir.ui.menu: document.menu_reports_document_manager |
59 | +DEL ir.ui.menu: document.menu_reports_document_manager1 |
60 | +DEL ir.ui.menu: knowledge.menu_document |
61 | +NEW ir.ui.view: document.view_files_by_user_graph |
62 | +DEL ir.ui.view: document.board_document_manager_form |
63 | +DEL ir.ui.view: document.board_document_manager_form1 |
64 | +DEL ir.ui.view: document.view_attachment_form_inherit |
65 | +DEL ir.ui.view: document.view_document_by_resourcetype_graph |
66 | +DEL ir.ui.view: document.view_document_storage_filter |
67 | +DEL ir.ui.view: document.view_document_storage_form |
68 | +DEL ir.ui.view: document.view_document_storage_tree |
69 | +DEL ir.ui.view: document.view_document_wall_form |
70 | +DEL ir.ui.view: document.view_document_wall_tree |
71 | +DEL ir.ui.view: document.view_files_by_partner_form |
72 | +DEL ir.ui.view: document.view_files_by_partner_graph |
73 | +DEL ir.ui.view: document.view_files_by_partner_tree |
74 | +DEL ir.ui.view: document.view_process_form_inherit1 |
75 | +DEL ir.ui.view: document.view_process_node_form_inherit1 |
76 | +DEL ir.ui.view: document.view_user_graph |
77 | |
78 | === added file 'document/migrations/7.0.2.1/post-migration.py' |
79 | --- document/migrations/7.0.2.1/post-migration.py 1970-01-01 00:00:00 +0000 |
80 | +++ document/migrations/7.0.2.1/post-migration.py 2014-06-04 22:01:29 +0000 |
81 | @@ -0,0 +1,76 @@ |
82 | +# -*- coding: utf-8 -*- |
83 | +############################################################################## |
84 | +# |
85 | +# OpenUpgrade, the free software migration tool for OpenERP |
86 | +# Copyright (C) 2014 Akretion (http://www.akretion.com/) |
87 | +# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
88 | +# |
89 | +# This program is free software: you can redistribute it and/or modify |
90 | +# it under the terms of the GNU Affero General Public License as |
91 | +# published by the Free Software Foundation, either version 3 of the |
92 | +# License, or (at your option) any later version. |
93 | +# |
94 | +# This program is distributed in the hope that it will be useful, |
95 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
96 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
97 | +# GNU Affero General Public License for more details. |
98 | +# |
99 | +# You should have received a copy of the GNU Affero General Public License |
100 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
101 | +# |
102 | +############################################################################## |
103 | + |
104 | +from openerp.openupgrade import openupgrade |
105 | +from openerp import pooler, SUPERUSER_ID |
106 | +import logging |
107 | + |
108 | +logger = logging.getLogger('OpenUpgrade') |
109 | + |
110 | + |
111 | +def migrate_filestore(cr, pool): |
112 | + cr.execute( |
113 | + "SELECT %s, %s FROM document_storage WHERE %s='filestore' " |
114 | + "ORDER BY id" % ( |
115 | + openupgrade.get_legacy_name('name'), |
116 | + openupgrade.get_legacy_name('path'), |
117 | + openupgrade.get_legacy_name('type'), |
118 | + )) |
119 | + filestore = cr.fetchall() |
120 | + if len(filestore) > 1: |
121 | + logger.error( |
122 | + "You have several filestore, which is very uncommon. OpenUpgrade " |
123 | + "will reconfigure your first filestore (%s), and you will have to " |
124 | + "merge the other filestore into your first filestore !" |
125 | + % filestore[0][0]) |
126 | + |
127 | + if filestore: |
128 | + logger.info( |
129 | + "Migrating the configuration of the filestore '%s' " |
130 | + "from document_storage to ir.config_parameter" % filestore[0][0]) |
131 | + path = filestore[0][1] |
132 | + logger.debug("Path of the first filestore = %s" % path) |
133 | + pool['ir.config_parameter'].create( |
134 | + cr, SUPERUSER_ID, { |
135 | + 'key': 'ir_attachment.location', |
136 | + 'value': 'file://%s' % path, |
137 | + }) |
138 | + logger.warning( |
139 | + "The new configuration of the filestore suppose that it is now " |
140 | + "located at <openerp_server_root>%s. It is not possible to have " |
141 | + "an absolute path any more." % path) |
142 | + logger.warning( |
143 | + "If your filestore is not located at <openerp_server_root>%s, you " |
144 | + "should create this directory and move it there, or update " |
145 | + "the System Parameter that has the key 'ir_attachment.location'." |
146 | + % path) |
147 | + logger.info( |
148 | + "If you want to know more about the filestore in 7.0, read " |
149 | + "the answer from Antony Lesuisse on this question : " |
150 | + "https://accounts.openerp.com/fr_FR/forum/Help-1/question/" |
151 | + "Where-are-document-Attachments-stored-529") |
152 | + |
153 | + |
154 | +@openupgrade.migrate() |
155 | +def migrate(cr, version): |
156 | + pool = pooler.get_pool(cr.dbname) |
157 | + migrate_filestore(cr, pool) |
158 | |
159 | === added file 'document/migrations/7.0.2.1/pre-migration.py' |
160 | --- document/migrations/7.0.2.1/pre-migration.py 1970-01-01 00:00:00 +0000 |
161 | +++ document/migrations/7.0.2.1/pre-migration.py 2014-06-04 22:01:29 +0000 |
162 | @@ -0,0 +1,37 @@ |
163 | +# -*- coding: utf-8 -*- |
164 | +############################################################################## |
165 | +# |
166 | +# OpenUpgrade, the free software migration tool for OpenERP |
167 | +# Copyright (C) 2014 Akretion (http://www.akretion.com/) |
168 | +# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
169 | +# |
170 | +# This program is free software: you can redistribute it and/or modify |
171 | +# it under the terms of the GNU Affero General Public License as |
172 | +# published by the Free Software Foundation, either version 3 of the |
173 | +# License, or (at your option) any later version. |
174 | +# |
175 | +# This program is distributed in the hope that it will be useful, |
176 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
177 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
178 | +# GNU Affero General Public License for more details. |
179 | +# |
180 | +# You should have received a copy of the GNU Affero General Public License |
181 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
182 | +# |
183 | +############################################################################## |
184 | + |
185 | +from openerp.openupgrade import openupgrade |
186 | + |
187 | + |
188 | +column_renames = { |
189 | + 'document_storage': [ |
190 | + ('name', None), |
191 | + ('path', None), |
192 | + ('type', None), |
193 | + ] |
194 | + } |
195 | + |
196 | + |
197 | +@openupgrade.migrate() |
198 | +def migrate(cr, version): |
199 | + openupgrade.rename_columns(cr, column_renames) |
The web page for my branch is broken. I have opened a ticket for the LP support team :
https:/ /answers. launchpad. net/launchpad/ +question/ 249758
I hope that it will be fixed shortly.