Merge lp:~therp-nl/openupgrade-addons/migration-analytic into lp:openupgrade-addons

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 8129
Proposed branch: lp:~therp-nl/openupgrade-addons/migration-analytic
Merge into: lp:openupgrade-addons
Diff against target: 135 lines (+121/-0)
3 files modified
analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt (+34/-0)
analytic/migrations/7.0.1.1/post-migration.py (+49/-0)
analytic/migrations/7.0.1.1/pre-migration.py (+38/-0)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/migration-analytic
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+175796@code.launchpad.net
To post a comment you must log in.
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 'analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt'
2--- analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt 1970-01-01 00:00:00 +0000
3+++ analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt 2013-07-19 10:42:28 +0000
4@@ -0,0 +1,34 @@
5+---analytic---
6+analytic / account.analytic.account / contact_id (many2one) : DEL relation: res.partner.address
7+# In 6.1, there is Two field partner_id [res.partner] and contact_id [res.partner.adress]
8+# In 7.0, there is on contact_id [res.partner] due to the merging of concept.
9+# -> Merging choice : select the old 'contact_id' (more precise) to fill 'partner_id' if 'contact_id' is defined.
10+
11+analytic / account.analytic.account / template_id (many2one) : NEW relation: account.analytic.account
12+# --> New concept available only in case of Account_analytic_accont.type="contract" : OK. (because 'contract' is new keys)
13+
14+analytic / account.analytic.account / manager_id (many2one) : NEW relation: res.users
15+# --> New concept: OK
16+
17+analytic / account.analytic.account / message_ids (one2many) : NEW relation: mail.message
18+# --> New concept: OK
19+
20+analytic / account.analytic.account / type (selection) : selection_keys is now '['contract', 'normal', 'template', 'view']' ('['normal', 'view']')
21+# New keys in selection : OK.
22+
23+analytic / account.analytic.account / type (selection) : now required, default = normal
24+# Value is required with default value : OK
25+
26+
27+new xml-id of model mail.message.subtype: analytic.mt_account_closed # mail.message.subtype is NEW : OK.
28+new xml-id of model mail.message.subtype: analytic.mt_account_opened # mail.message.subtype is NEW : OK.
29+new xml-id of model mail.message.subtype: analytic.mt_account_pending # mail.message.subtype is NEW : OK.
30+
31+new xml-id of model ir.sequence.type: analytic.seq_type_analytic_account_main
32+### previously in module "account" and named "seq_type_analytic_account". Rename xml : OK
33+
34+new xml-id of model ir.sequence: analytic.seq_analytic_account_base
35+### previously in module "account" and named "seq_analytic_account". Rename xml : OK
36+
37+### System XML IDs belows : (Nothing to do)
38+new xml-id of model ir.ui.view: analytic.view_account_analytic_account_form
39
40=== added file 'analytic/migrations/7.0.1.1/post-migration.py'
41--- analytic/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
42+++ analytic/migrations/7.0.1.1/post-migration.py 2013-07-19 10:42:28 +0000
43@@ -0,0 +1,49 @@
44+# -*- coding: utf-8 -*-
45+##############################################################################
46+#
47+# OpenERP, Open Source Management Solution
48+# This migration script copyright (C) 2013-today Sylvain LE GAL
49+#
50+# This program is free software: you can redistribute it and/or modify
51+# it under the terms of the GNU Affero General Public License as
52+# published by the Free Software Foundation, either version 3 of the
53+# License, or (at your option) any later version.
54+#
55+# This program is distributed in the hope that it will be useful,
56+# but WITHOUT ANY WARRANTY; without even the implied warranty of
57+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58+# GNU Affero General Public License for more details.
59+#
60+# You should have received a copy of the GNU Affero General Public License
61+# along with this program. If not, see <http://www.gnu.org/licenses/>.
62+#
63+##############################################################################
64+
65+from openupgrade import openupgrade
66+from openupgrade import openupgrade_70
67+from openerp import pooler, SUPERUSER_ID
68+
69+def fill_manager_id(cr, pool):
70+ """
71+ Fill the new field 'manager_id' depending on account_analytic_account.partner_id.user_id
72+ """
73+ analytic_obj = pool.get('account.analytic.account')
74+ cr.execute("""SELECT
75+ account_analytic_account.id as id,
76+ res_users.id as manager_id
77+ FROM account_analytic_account
78+ INNER JOIN res_partner on res_partner.id = account_analytic_account.partner_id
79+ INNER JOIN res_users on res_partner.user_id = res_users.id; """)
80+ for row in cr.dictfetchall():
81+ vals = {
82+ 'manager_id' : row['manager_id'],
83+ }
84+ analytic_obj.write(cr, SUPERUSER_ID, row['id'], vals)
85+
86+@openupgrade.migrate()
87+def migrate(cr, version):
88+ pool = pooler.get_pool(cr.dbname)
89+ openupgrade_70.set_partner_id_from_partner_address_id(
90+ cr, pool, 'account.analytic.account',
91+ 'partner_id', openupgrade.get_legacy_name('contact_id'))
92+ fill_manager_id(cr, pool)
93
94=== added file 'analytic/migrations/7.0.1.1/pre-migration.py'
95--- analytic/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
96+++ analytic/migrations/7.0.1.1/pre-migration.py 2013-07-19 10:42:28 +0000
97@@ -0,0 +1,38 @@
98+# -*- coding: utf-8 -*-
99+##############################################################################
100+#
101+# OpenERP, Open Source Management Solution
102+# This migration script copyright (C) 2013-today Sylvain LE GAL
103+#
104+# This program is free software: you can redistribute it and/or modify
105+# it under the terms of the GNU Affero General Public License as
106+# published by the Free Software Foundation, either version 3 of the
107+# License, or (at your option) any later version.
108+#
109+# This program is distributed in the hope that it will be useful,
110+# but WITHOUT ANY WARRANTY; without even the implied warranty of
111+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
112+# GNU Affero General Public License for more details.
113+#
114+# You should have received a copy of the GNU Affero General Public License
115+# along with this program. If not, see <http://www.gnu.org/licenses/>.
116+#
117+##############################################################################
118+
119+from openupgrade import openupgrade
120+
121+xmlid_renames = [
122+ ('account.seq_type_analytic_account', 'analytic.seq_type_analytic_account_main'),
123+ ('account.seq_analytic_account', 'analytic.seq_analytic_account_base'),
124+]
125+
126+column_renames = {
127+ 'account_analytic_account': [
128+ ('contact_id', openupgrade.get_legacy_name('contact_id'))
129+ ]
130+ }
131+
132+@openupgrade.migrate()
133+def migrate(cr, version):
134+ openupgrade.rename_xmlids(cr, xmlid_renames)
135+ openupgrade.rename_columns(cr, column_renames)

Subscribers

People subscribed via source and target branches