credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05616
lp:~savoirfairelinux-openerp/openupgrade-addons/crm_claim_stage_data into lp:openupgrade-addons
Sandy Carter (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux-openerp/openupgrade-addons/crm_claim_stage_data into lp:openupgrade-addons.
Requested reviews:
Sylvain LE GAL (GRAP) (sylvain-legal): code review, no test
For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/openupgrade-addons/crm_claim_stage_data/+merge/193434
Migration scripts for crm and crm_claim
columns are depricated properly
more xml data is loaded
crm_claim_stages are migrated
old stages are deprecated
new stages are derived from old states
user may need to remake old stages ( this avoids clutter of old stages making their way into 7.0)
--
https://code.launchpad.net/~savoirfairelinux-openerp/openupgrade-addons/crm_claim_stage_data/+merge/193434
Your team OpenUpgrade Committers is subscribed to branch lp:openupgrade-addons.
=== added file 'crm/migrations/7.0.1.0/data.xml'
--- crm/migrations/7.0.1.0/data.xml 1970-01-01 00:00:00 +0000
+++ crm/migrations/7.0.1.0/data.xml 2013-10-31 14:56:00 +0000
@@ -0,0 +1,82 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <!-- Mail Alias -->
+ <record model="mail.alias" id="default_sales_alias">
+ <field name="alias_name">sales</field>
+ <field name="alias_model_id" ref="model_crm_lead"/>
+ <field name="alias_user_id" ref="base.user_root"/>
+ <field name="alias_defaults">{'type':'lead'}</field>
+ </record>
+
+ <!-- Crm stages -->
+ <record model="crm.case.stage" id="stage_lead6">
+ <field name="name">Lost</field>
+ <field eval="1" name="case_default"/>
+ <field eval="True" name="fold"/>
+ <field eval="1" name="on_change"/>
+ <field name="state">cancel</field>
+ <field eval="0" name="probability"/>
+ <field eval="140" name="sequence"/>
+ <field name="type">opportunity</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead1">
+ <field name="name">New</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">draft</field>
+ <field eval="0" name="probability"/>
+ <field eval="10" name="sequence"/>
+ <field name="type">both</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead2">
+ <field name="name">Qualification</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">open</field>
+ <field eval="20" name="probability"/>
+ <field eval="100" name="sequence"/>
+ <field name="type">opportunity</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead3">
+ <field name="name">Proposition</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">open</field>
+ <field eval="40" name="probability"/>
+ <field eval="110" name="sequence"/>
+ <field name="type">opportunity</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead4">
+ <field name="name">Negotiation</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">open</field>
+ <field eval="60" name="probability"/>
+ <field eval="120" name="sequence"/>
+ <field name="type">opportunity</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead5">
+ <field name="name">Won</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">done</field>
+ <field eval="100" name="probability"/>
+ <field eval="130" name="sequence"/>
+ <field eval="1" name="on_change"/>
+ <field name="type">opportunity</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead7">
+ <field name="name">Dead</field>
+ <field eval="1" name="case_default"/>
+ <field eval="False" name="fold"/>
+ <field name="state">cancel</field>
+ <field eval="0" name="probability"/>
+ <field eval="30" name="sequence"/>
+ <field name="type">lead</field>
+ </record>
+ <record model="crm.case.stage" id="stage_lead8">
+ <field name="name">Opportunity</field>
+ <field eval="1" name="case_default"/>
+ <field name="state">open</field>
+ <field eval="20" name="probability"/>
+ <field eval="20" name="sequence"/>
+ <field name="type">lead</field>
+ </record>
+ </data>
+</openerp>
=== added file 'crm/migrations/7.0.1.0/post-migration.py'
--- crm/migrations/7.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ crm/migrations/7.0.1.0/post-migration.py 2013-10-31 14:56:00 +0000
@@ -0,0 +1,64 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Savoir-faire Linux
+# (<http://www.savoirfairelinux.com>).
+#
+# 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 openerp import pooler, SUPERUSER_ID
+from openupgrade import openupgrade
+
+
+def create_section_mail_aliases(cr, pool, uid=SUPERUSER_ID):
+ """
+ Create mail aliases for each existing crm.case.section
+ """
+ # Pools
+ crm_case_section = pool.get('crm.case.section')
+ mail_alias = pool.get('mail.alias')
+ # Get case_sections
+ openupgrade.logged_query(cr, """SELECT id, name from crm_case_section;""")
+ vals = cr.fetchall()
+ # Create alias for each section
+ for id, name in vals:
+ fields = {
+ 'alias_name': name,
+ 'alias_defaults': {'section_id': id, 'type': 'lead'},
+ }
+ alias_id = mail_alias.create_unique_alias(cr, uid, fields,
+ model_name="crm.lead")
+ crm_case_section.write(cr, uid, [id], {'alias_id': alias_id})
+
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ """
+ * Create mail aliases for crm case section,
+ * Load xml data (Mail alias and updates to CRM stages)
+ * Change categ_id to many to many
+ """
+ pool = pooler.get_pool(cr.dbname)
+ openupgrade.load_xml(
+ cr, 'crm',
+ 'migrations/7.0.1.0/data.xml')
+ create_section_mail_aliases(cr, pool)
+ # Migrate m2o categ_id to m2m categ_ids
+ openupgrade.m2o_to_m2m(cr, pool.get('crm.lead'), 'crm_lead', 'categ_ids',
+ openupgrade.get_legacy_name('categ_id'))
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'crm/migrations/7.0.1.0/pre-migration.py'
--- crm/migrations/7.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ crm/migrations/7.0.1.0/pre-migration.py 2013-10-31 14:56:00 +0000
@@ -0,0 +1,62 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Savoir-faire Linux
+# (<http://www.savoirfairelinux.com>).
+#
+# 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
+
+column_renames = {
+ 'crm_case_section': [
+ ('allow_unlink', None),
+ ],
+ 'crm_lead': [
+ ('birthdate', None),
+ ('categ_id', None), # many2one -> many2many
+ ('email', None),
+ ('optin', None),
+ ('optout', 'opt_out'),
+ ('partner_address_id', None),
+ ],
+ 'crm_meeting': [
+ ('categ_id', None),
+ ('date_action_last', None),
+ ('date_action_next', None),
+ ('email_from', None),
+ ('partner_address_id', None),
+ ('partner_id', None),
+ ('recurrent_uid', None),
+ ('section_id', None),
+ ],
+ 'crm_phonecall': [
+ ('partner_address_id', None),
+ ],
+ 'crm_segmentation': [
+ ('som_interval', None),
+ ('som_interval_decrease', None),
+ ('som_interval_default', None),
+ ('som_interval_max', None),
+ ],
+}
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ openupgrade.rename_columns(cr, column_renames)
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'crm_claim/migrations/7.0.1.0/data.xml'
--- crm_claim/migrations/7.0.1.0/data.xml 1970-01-01 00:00:00 +0000
+++ crm_claim/migrations/7.0.1.0/data.xml 2013-10-31 14:56:00 +0000
@@ -0,0 +1,37 @@
+<?xml version = "1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--
+ Case Stage
+ -->
+
+ <record model="crm.claim.stage" id="stage_claim1">
+ <field name="name">New</field>
+ <field name="state">draft</field>
+ <field name="sequence">26</field>
+ <field name="case_default" eval="True"/>
+ </record>
+ <record model="crm.claim.stage" id="stage_claim5">
+ <field name="name">In Progress</field>
+ <field name="state">open</field>
+ <field name="sequence">27</field>
+ <field name="case_default" eval="True"/>
+ </record>
+ <record model="crm.claim.stage" id="stage_claim2">
+ <field name="name">Settled</field>
+ <field name="state">done</field>
+ <field name="sequence">28</field>
+ <field name="case_default" eval="True"/>
+ </record>
+ <record model="crm.claim.stage" id="stage_claim3">
+ <field name="name">Rejected</field>
+ <field name="state">cancel</field>
+ <field name="sequence">29</field>
+ <field name="case_default" eval="True"/>
+ <field name="case_refused" eval="True"/>
+ <field name="fold" eval="True"/>
+ </record>
+
+ </data>
+</openerp>
=== added file 'crm_claim/migrations/7.0.1.0/post-migration.py'
--- crm_claim/migrations/7.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
+++ crm_claim/migrations/7.0.1.0/post-migration.py 2013-10-31 14:56:00 +0000
@@ -0,0 +1,56 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Savoir-faire Linux
+# (<http://www.savoirfairelinux.com>).
+#
+# 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
+
+
+def post_case_claim_stage(cr):
+ """
+ Set 6.1 states as 7.0 stages
+ """
+ stage_state_renames = [
+ ("draft", "draft"),
+ ("open", "open"),
+ ("open", "pending"),
+ ("done", "done"),
+ ("cancel", "cancel")
+ ]
+ # Point new stage_id according to old state_id
+ for stage_rename in stage_state_renames:
+ openupgrade.logged_query(cr, """
+ UPDATE crm_claim
+ SET stage_id = (SELECT id
+ FROM crm_claim_stage
+ WHERE state = %s)
+ WHERE state = %s;
+ """, stage_rename)
+
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ # Add stages to crm_claim_stage
+ openupgrade.load_xml(
+ cr, 'crm_claim',
+ 'migrations/7.0.1.0/data.xml')
+ post_case_claim_stage(cr)
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'crm_claim/migrations/7.0.1.0/pre-migration.py'
--- crm_claim/migrations/7.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
+++ crm_claim/migrations/7.0.1.0/pre-migration.py 2013-10-31 14:56:00 +0000
@@ -0,0 +1,41 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Savoir-faire Linux
+# (<http://www.savoirfairelinux.com>).
+#
+# 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 openerp.openupgrade import openupgrade
+
+column_renames = {
+ 'crm_claim': [
+ ('partner_address_id', None),
+ ('stage_id', None),
+ ]
+}
+
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ openupgrade.rename_columns(cr, column_renames)
+ # Constraint changed from crm_case_stage to crm_claim_stage
+ openupgrade.logged_query(cr, """
+ ALTER TABLE crm_claim
+ DROP CONSTRAINT IF EXISTS crm_claim_stage_id_fkey;""")
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'crm_claim/migrations/7.0.1.0/user_notes.txt'
--- crm_claim/migrations/7.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
+++ crm_claim/migrations/7.0.1.0/user_notes.txt 2013-10-31 14:56:00 +0000
@@ -0,0 +1,6 @@
+States from 6.1 are referred to Stages of 7.0.
+
+The pending state is grouped under 'In progress'.
+
+Stages from 6.1 are backed up as openupgrade_legacy_7_0_stage_id.
+Custom stages must be recreated as they have moved from crm_case_stages to crm_claim_stages
Follow ups