Merge lp:~therp-nl/openupgrade-addons/6.0-sale_journal_picking_journals into lp:openupgrade-addons/6.0

Proposed by Stefan Rijnhart (Opener) on 2012-11-15
Status: Merged
Merged at revision: 4788
Proposed branch: lp:~therp-nl/openupgrade-addons/6.0-sale_journal_picking_journals
Merge into: lp:openupgrade-addons/6.0
Diff against target: 100 lines (+85/-1)
3 files modified
sale_journal/migrations/6.0.1.0/post-migration.py (+51/-0)
sale_journal/migrations/6.0.1.0/pre-migration.py (+32/-0)
sale_journal/migrations/6.0.1.0/user_notes.txt (+2/-1)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.0-sale_journal_picking_journals
Reviewer Review Type Date Requested Status
OpenUpgrade Committers 2012-11-15 Pending
Review via email: mp+134564@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'sale_journal/migrations/6.0.1.0/post-migration.py'
2--- sale_journal/migrations/6.0.1.0/post-migration.py 1970-01-01 00:00:00 +0000
3+++ sale_journal/migrations/6.0.1.0/post-migration.py 2012-11-15 20:32:27 +0000
4@@ -0,0 +1,51 @@
5+# -*- coding: utf-8 -*-
6+##############################################################################
7+#
8+# OpenERP, Open Source Management Solution
9+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as
13+# published by the Free Software Foundation, either version 3 of the
14+# License, or (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25+
26+import pooler
27+from openupgrade import openupgrade
28+
29+def migrate_picking_journal(cr, pool):
30+ """
31+ Sale picking journals are now stock journals,
32+ defined in the stock module
33+ """
34+ stock_journal_obj = pool.get('stock.journal')
35+ cr.execute("""
36+ SELECT id, name, user_id
37+ FROM sale_journal_picking_journal
38+ """)
39+ journal_map = []
40+ for (sale_journal_id, name, user_id) in cr.fetchall():
41+ stock_journal_id = stock_journal_obj.create(
42+ cr, 1, {'name': name, 'user_id': user_id})
43+ journal_map.append((sale_journal_id, stock_journal_id))
44+ for (sale_journal_id, stock_journal_id) in journal_map:
45+ cr.execute(
46+ "UPDATE stock_picking "
47+ "SET stock_journal_id = %s "
48+ "WHERE " + openupgrade.get_legacy_name('journal_id') + " = %s",
49+ (stock_journal_id, sale_journal_id)
50+ )
51+
52+@openupgrade.migrate()
53+def migrate(cr, version):
54+ pool = pooler.get_pool(cr.dbname)
55+ migrate_picking_journal(cr, pool)
56
57=== added file 'sale_journal/migrations/6.0.1.0/pre-migration.py'
58--- sale_journal/migrations/6.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
59+++ sale_journal/migrations/6.0.1.0/pre-migration.py 2012-11-15 20:32:27 +0000
60@@ -0,0 +1,32 @@
61+# -*- coding: utf-8 -*-
62+##############################################################################
63+#
64+# OpenERP, Open Source Management Solution
65+# This migration script copyright (C) 2012 Therp BV (<http://therp.nl>)
66+#
67+# This program is free software: you can redistribute it and/or modify
68+# it under the terms of the GNU Affero General Public License as
69+# published by the Free Software Foundation, either version 3 of the
70+# License, or (at your option) any later version.
71+#
72+# This program is distributed in the hope that it will be useful,
73+# but WITHOUT ANY WARRANTY; without even the implied warranty of
74+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
75+# GNU Affero General Public License for more details.
76+#
77+# You should have received a copy of the GNU Affero General Public License
78+# along with this program. If not, see <http://www.gnu.org/licenses/>.
79+#
80+##############################################################################
81+
82+from openupgrade import openupgrade
83+
84+column_renames = {
85+ 'stock_picking': [
86+ ('journal_id', openupgrade.get_legacy_name('journal_id')),
87+ ]
88+ }
89+
90+@openupgrade.migrate()
91+def migrate(cr, version):
92+ openupgrade.rename_columns(cr, column_renames)
93
94=== modified file 'sale_journal/migrations/6.0.1.0/user_notes.txt'
95--- sale_journal/migrations/6.0.1.0/user_notes.txt 2012-06-07 14:51:52 +0000
96+++ sale_journal/migrations/6.0.1.0/user_notes.txt 2012-11-15 20:32:27 +0000
97@@ -1,1 +1,2 @@
98-Nothing to do for module 'sale_journal'
99+Sale picking journals are migrated to stock journals
100+

Subscribers

People subscribed via source and target branches