← Back to team overview

credativ team mailing list archive

lp:~therp-nl/openupgrade-addons/6.1-stock_migrate_workitems_in_act_cancel_inv into lp:openupgrade-addons

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.1-stock_migrate_workitems_in_act_cancel_inv into lp:openupgrade-addons.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-stock_migrate_workitems_in_act_cancel_inv/+merge/130100
-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-stock_migrate_workitems_in_act_cancel_inv/+merge/130100
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.1-stock_migrate_workitems_in_act_cancel_inv into lp:openupgrade-addons.
=== added file 'stock/migrations/6.1.1.1/pre-migration.py'
--- stock/migrations/6.1.1.1/pre-migration.py	1970-01-01 00:00:00 +0000
+++ stock/migrations/6.1.1.1/pre-migration.py	2012-10-17 12:11:25 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This module copyright (C) 2012 Therp BV (<http://therp.nl>).
+#
+#    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
+
+def update_wkf_items(cr):
+    """ 
+    Replace references to act_cancel_inv with
+    references to act_cancel in workflow workitems
+    """
+    openupgrade.logged_query(cr, """
+            UPDATE wkf_workitem
+            SET act_id = (
+                SELECT res_id FROM ir_model_data
+                WHERE module = 'stock'
+                AND name = 'act_cancel')
+            WHERE act_id = (
+                SELECT res_id FROM ir_model_data
+                WHERE module = 'stock'
+                AND name = 'act_cancel_inv')
+    """)
+
+@openupgrade.migrate()
+def migrate(cr, version):
+    update_wkf_items(cr)

=== modified file 'stock/migrations/6.1.1.1/user_notes.txt'
--- stock/migrations/6.1.1.1/user_notes.txt	2012-06-06 09:24:16 +0000
+++ stock/migrations/6.1.1.1/user_notes.txt	2012-10-17 12:11:25 +0000
@@ -1,1 +1,2 @@
-Nothing to do for module 'stock'
+This migration script updates existing workflow items that have an obsolete cancelled state.
+


Follow ups