credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05307
[Merge] lp:~therp-nl/openupgrade-addons/migration-analytic into lp:openupgrade-addons
Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/migration-analytic into lp:openupgrade-addons.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/migration-analytic/+merge/175796
Supersedes https://code.launchpad.net/~sylvain-legal/openupgrade-addons/migration-analytic/+merge/174751
--
https://code.launchpad.net/~therp-nl/openupgrade-addons/migration-analytic/+merge/175796
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/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-19 10:42:28 +0000
@@ -0,0 +1,34 @@
+---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.
+
+new xml-id of model ir.sequence.type: analytic.seq_type_analytic_account_main
+### previously in module "account" and named "seq_type_analytic_account". Rename xml : OK
+
+new xml-id of model ir.sequence: analytic.seq_analytic_account_base
+### previously in module "account" and named "seq_analytic_account". Rename xml : OK
+
+### System XML IDs belows : (Nothing to do)
+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-19 10:42:28 +0000
@@ -0,0 +1,49 @@
+# -*- 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 fill_manager_id(cr, pool):
+ """
+ Fill the new field 'manager_id' depending on account_analytic_account.partner_id.user_id
+ """
+ analytic_obj = pool.get('account.analytic.account')
+ cr.execute("""SELECT
+ account_analytic_account.id as id,
+ res_users.id as manager_id
+ FROM account_analytic_account
+ INNER JOIN res_partner on res_partner.id = account_analytic_account.partner_id
+ INNER JOIN res_users on res_partner.user_id = res_users.id; """)
+ for row in cr.dictfetchall():
+ vals = {
+ 'manager_id' : row['manager_id'],
+ }
+ analytic_obj.write(cr, SUPERUSER_ID, row['id'], vals)
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ pool = pooler.get_pool(cr.dbname)
+ openupgrade_70.set_partner_id_from_partner_address_id(
+ cr, pool, 'account.analytic.account',
+ 'partner_id', openupgrade.get_legacy_name('contact_id'))
+ fill_manager_id(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-19 10:42:28 +0000
@@ -0,0 +1,38 @@
+# -*- 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
+
+xmlid_renames = [
+ ('account.seq_type_analytic_account', 'analytic.seq_type_analytic_account_main'),
+ ('account.seq_analytic_account', 'analytic.seq_analytic_account_base'),
+]
+
+column_renames = {
+ 'account_analytic_account': [
+ ('contact_id', openupgrade.get_legacy_name('contact_id'))
+ ]
+ }
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ openupgrade.rename_xmlids(cr, xmlid_renames)
+ openupgrade.rename_columns(cr, column_renames)
Follow ups