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
=== added file 'analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt'
--- analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt 1970-01-01 00:00:00 +0000
+++ analytic/migrations/7.0.1.1/openupgrade_analysis_worker.txt 2013-07-19 10:42:28 +0000
@@ -0,0 +1,34 @@
1---analytic---
2analytic / account.analytic.account / contact_id (many2one) : DEL relation: res.partner.address
3# In 6.1, there is Two field partner_id [res.partner] and contact_id [res.partner.adress]
4# In 7.0, there is on contact_id [res.partner] due to the merging of concept.
5# -> Merging choice : select the old 'contact_id' (more precise) to fill 'partner_id' if 'contact_id' is defined.
6
7analytic / account.analytic.account / template_id (many2one) : NEW relation: account.analytic.account
8# --> New concept available only in case of Account_analytic_accont.type="contract" : OK. (because 'contract' is new keys)
9
10analytic / account.analytic.account / manager_id (many2one) : NEW relation: res.users
11# --> New concept: OK
12
13analytic / account.analytic.account / message_ids (one2many) : NEW relation: mail.message
14# --> New concept: OK
15
16analytic / account.analytic.account / type (selection) : selection_keys is now '['contract', 'normal', 'template', 'view']' ('['normal', 'view']')
17# New keys in selection : OK.
18
19analytic / account.analytic.account / type (selection) : now required, default = normal
20# Value is required with default value : OK
21
22
23new xml-id of model mail.message.subtype: analytic.mt_account_closed # mail.message.subtype is NEW : OK.
24new xml-id of model mail.message.subtype: analytic.mt_account_opened # mail.message.subtype is NEW : OK.
25new xml-id of model mail.message.subtype: analytic.mt_account_pending # mail.message.subtype is NEW : OK.
26
27new xml-id of model ir.sequence.type: analytic.seq_type_analytic_account_main
28### previously in module "account" and named "seq_type_analytic_account". Rename xml : OK
29
30new xml-id of model ir.sequence: analytic.seq_analytic_account_base
31### previously in module "account" and named "seq_analytic_account". Rename xml : OK
32
33### System XML IDs belows : (Nothing to do)
34new xml-id of model ir.ui.view: analytic.view_account_analytic_account_form
035
=== added file 'analytic/migrations/7.0.1.1/post-migration.py'
--- analytic/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ analytic/migrations/7.0.1.1/post-migration.py 2013-07-19 10:42:28 +0000
@@ -0,0 +1,49 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2013-today Sylvain LE GAL
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23from openupgrade import openupgrade_70
24from openerp import pooler, SUPERUSER_ID
25
26def fill_manager_id(cr, pool):
27 """
28 Fill the new field 'manager_id' depending on account_analytic_account.partner_id.user_id
29 """
30 analytic_obj = pool.get('account.analytic.account')
31 cr.execute("""SELECT
32 account_analytic_account.id as id,
33 res_users.id as manager_id
34 FROM account_analytic_account
35 INNER JOIN res_partner on res_partner.id = account_analytic_account.partner_id
36 INNER JOIN res_users on res_partner.user_id = res_users.id; """)
37 for row in cr.dictfetchall():
38 vals = {
39 'manager_id' : row['manager_id'],
40 }
41 analytic_obj.write(cr, SUPERUSER_ID, row['id'], vals)
42
43@openupgrade.migrate()
44def migrate(cr, version):
45 pool = pooler.get_pool(cr.dbname)
46 openupgrade_70.set_partner_id_from_partner_address_id(
47 cr, pool, 'account.analytic.account',
48 'partner_id', openupgrade.get_legacy_name('contact_id'))
49 fill_manager_id(cr, pool)
050
=== added file 'analytic/migrations/7.0.1.1/pre-migration.py'
--- analytic/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ analytic/migrations/7.0.1.1/pre-migration.py 2013-07-19 10:42:28 +0000
@@ -0,0 +1,38 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This migration script copyright (C) 2013-today Sylvain LE GAL
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openupgrade import openupgrade
23
24xmlid_renames = [
25 ('account.seq_type_analytic_account', 'analytic.seq_type_analytic_account_main'),
26 ('account.seq_analytic_account', 'analytic.seq_analytic_account_base'),
27]
28
29column_renames = {
30 'account_analytic_account': [
31 ('contact_id', openupgrade.get_legacy_name('contact_id'))
32 ]
33 }
34
35@openupgrade.migrate()
36def migrate(cr, version):
37 openupgrade.rename_xmlids(cr, xmlid_renames)
38 openupgrade.rename_columns(cr, column_renames)

Subscribers

People subscribed via source and target branches