← Back to team overview

credativ team mailing list archive

[Merge] lp:~sylvain-legal/openupgrade-addons/migration-analytic into lp:openupgrade-addons

 

Sylvain LE GAL (GRAP) has proposed merging lp:~sylvain-legal/openupgrade-addons/migration-analytic into lp:openupgrade-addons.

Commit message:
[ADD] migration scripts for 'analytic' module.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~sylvain-legal/openupgrade-addons/migration-analytic/+merge/174751

Hi.

[ADD] migration scripts for 'analytic' module.
- pre-migration.py ; 
- post-migration.py ("empty")
- openupgrade_analysis_worker.txt. (notes about analysis)

Warning : do not merge before an other branch is merged in an other project (openupgrade-server), because 'pre-migration.py' use get_partner_id_from_partner_address_id() function.

'OpenUpgrade-server' Prerequisite Branch : 
(https://code.launchpad.net/~sylvain-legal/openupgrade-server/three-functions-for-addons-migration/+merge/174668)

  
-- 
https://code.launchpad.net/~sylvain-legal/openupgrade-addons/migration-analytic/+merge/174751
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~sylvain-legal/openupgrade-addons/migration-analytic into lp:openupgrade-addons.
=== 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-15 13:26:32 +0000
@@ -0,0 +1,32 @@
+---analytic---
+analytic     / account.analytic.account / contact_id (many2one)         : DEL relation: res.partner.address
+# In 6.1, there is Two field partner_id [res.partner] and contact_id [res.partner.adress]
+# In 7.0, there is on contact_id [res.partner] due to the merging of concept.
+# -> Merging choice : select the old 'contact_id' (more precise) to fill 'partner_id' if 'contact_id' is defined.
+
+analytic     / account.analytic.account / template_id (many2one)        : NEW relation: account.analytic.account
+# --> New concept available only in case of Account_analytic_accont.type="contract" : OK. (because 'contract' is new keys)
+
+analytic     / account.analytic.account / manager_id (many2one)         : NEW relation: res.users
+# --> New concept: OK
+
+analytic     / account.analytic.account / message_ids (one2many)        : NEW relation: mail.message
+# --> New concept: OK 
+
+analytic     / account.analytic.account / type (selection)              : selection_keys is now '['contract', 'normal', 'template', 'view']' ('['normal', 'view']')
+# New keys in selection : OK.
+
+analytic     / account.analytic.account / type (selection)              : now required, default = normal
+# Value is required with default value : OK 
+
+
+new xml-id of model mail.message.subtype: analytic.mt_account_closed    # mail.message.subtype is NEW : OK.
+new xml-id of model mail.message.subtype: analytic.mt_account_opened    # mail.message.subtype is NEW : OK.
+new xml-id of model mail.message.subtype: analytic.mt_account_pending   # mail.message.subtype is NEW : OK.
+
+
+### System XML IDs belows : Nothing to do)
+
+new xml-id of model ir.sequence.type: analytic.seq_type_analytic_account_main
+new xml-id of model ir.sequence: analytic.seq_analytic_account_base
+new xml-id of model ir.ui.view: analytic.view_account_analytic_account_form

=== 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-15 13:26:32 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2013-today Sylvain LE GAL
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+from openupgrade import openupgrade_70
+from openerp import pooler, SUPERUSER_ID
+
+def migrate_partner_address(cr, pool):
+    """ 
+    Manage partner changes in 'account.analytic.account'.
+    Use obsolete 'contact_id' field to fill 'partner_id' if 'contact_id' is not null.
+    Otherwise, use partner_id.
+    """
+    analytic_obj = pool.get('account.analytic.account')
+    cr.execute("""
+        SELECT id, contact_id
+        FROM account_analytic_account
+        WHERE contact_id is not null; """)
+    for row in cr.dictfetchall():
+        vals = {
+            'partner_id': openupgrade_70.get_partner_id_from_partner_address_id(cr, row['contact_id']),
+            }
+        analytic_obj.write(cr, SUPERUSER_ID, row['id'], vals)
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pool = pooler.get_pool(cr.dbname)
+    migrate_partner_address(cr, pool)

=== 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-15 13:26:32 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This migration script copyright (C) 2013-today Sylvain LE GAL
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openupgrade import openupgrade
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    pass

=== added file 'product/migrations/7.0.1.1/data.xml'
--- product/migrations/7.0.1.1/data.xml	1970-01-01 00:00:00 +0000
+++ product/migrations/7.0.1.1/data.xml	2013-07-15 13:26:32 +0000
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- assign new name, as this is the primary key
+             by which precisions are retrieved -->
+        <record id="decimal_price" model="decimal.precision">
+            <field name="name">Product Price</field>
+        </record>
+    </data>
+</openerp>

=== modified file 'product/migrations/7.0.1.1/post-migration.py'
--- product/migrations/7.0.1.1/post-migration.py	2013-07-12 14:42:11 +0000
+++ product/migrations/7.0.1.1/post-migration.py	2013-07-15 13:26:32 +0000
@@ -20,8 +20,9 @@
 ##############################################################################
 
 from openupgrade import openupgrade
-from openerp import pooler, SUPERUSER_ID
 
 @openupgrade.migrate()
 def migrate(cr, version):
-    pass
+    openupgrade.load_xml(
+        cr, 'product',
+        'migrations/7.0.1.1/data.xml')


Follow ups