← Back to team overview

credativ team mailing list archive

[Merge] lp:~pedro.baeza/openupgrade-addons/6.1-fetchmail into lp:openupgrade-addons/6.1

 

Pedro Manuel Baeza has proposed merging lp:~pedro.baeza/openupgrade-addons/6.1-fetchmail into lp:openupgrade-addons/6.1.

Commit message:
[ADD] Migration script for module 'fetchmail'.

Requested reviews:
  Stefan Rijnhart (Therp) (stefan-therp)
  Paulius Sladkevičius @ hbee (komsas)

For more details, see:
https://code.launchpad.net/~pedro.baeza/openupgrade-addons/6.1-fetchmail/+merge/133469

[ADD] Migration script for module 'fetchmail'.
-- 
https://code.launchpad.net/~pedro.baeza/openupgrade-addons/6.1-fetchmail/+merge/133469
Your team OpenUpgrade Committers is subscribed to branch lp:openupgrade-addons/6.1.
=== added file 'fetchmail/migrations/6.1.1.0/pre-migration.py'
--- fetchmail/migrations/6.1.1.0/pre-migration.py	1970-01-01 00:00:00 +0000
+++ fetchmail/migrations/6.1.1.0/pre-migration.py	2013-07-18 09:32:28 +0000
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This module copyright (C) 2012 Serv. tecnólogicos avanzados - Pedro M. Baeza (<http://www.serviciosbaeza.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/>.
+#
+##############################################################################
+
+import os
+from osv import osv
+import logging
+from openerp.openupgrade import openupgrade
+
+me = __file__
+
+column_renames = {
+    'mail_message': [
+        ('server_id', 'fetchmail_server_id'),
+        ],
+    }
+
+table_renames = [
+    ('email_server', 'fetchmail_server'),
+    ]
+
+model_renames = [
+    ('email.server', 'fetchmail.server'),
+    ]
+
+def _change_waiting_state(cr):
+    openupgrade.logged_query(cr, "UPDATE fetchmail_server SET state='draft' WHERE state='waiting'")
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    if openupgrade.table_exists(cr, 'email_server'):
+        openupgrade.rename_tables(cr, table_renames)
+        openupgrade.rename_columns(cr, column_renames)
+        openupgrade.rename_models(cr, model_renames)
+    _change_waiting_state(cr)


References