credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05638
[Merge] lp:~savoirfairelinux-openerp/openupgrade-addons/crm_migrations into lp:openupgrade-addons
Sandy Carter (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux-openerp/openupgrade-addons/crm_migrations into lp:openupgrade-addons.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/openupgrade-addons/crm_migrations/+merge/195277
Migration scripts for crm
(split crm and crm_claim from https://code.launchpad.net/~savoirfairelinux-openerp/openupgrade-addons/crm_claim_stage_data/+merge/193434)
columns are depricated properly
more xml data is loaded
--
https://code.launchpad.net/~savoirfairelinux-openerp/openupgrade-addons/crm_migrations/+merge/195277
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~savoirfairelinux-openerp/openupgrade-addons/crm_migrations into 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-11-14 18:05:18 +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-11-14 18:05:18 +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-11-14 18:05:18 +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: