Merge lp:~openupgrade-committers/openupgrade-addons/7.0-account_analytic_plans-pedro.baeza into lp:openupgrade-addons

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 8158
Proposed branch: lp:~openupgrade-committers/openupgrade-addons/7.0-account_analytic_plans-pedro.baeza
Merge into: lp:openupgrade-addons
Diff against target: 70 lines (+56/-0)
3 files modified
account_analytic_plans/migrations/7.0.1.0/openupgrade_analysis_work.txt (+10/-0)
account_analytic_plans/migrations/7.0.1.0/pre-migration.py (+44/-0)
account_analytic_plans/migrations/7.0.1.0/user_notes.txt (+2/-0)
To merge this branch: bzr merge lp:~openupgrade-committers/openupgrade-addons/7.0-account_analytic_plans-pedro.baeza
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Stefan Rijnhart (Opener) Needs Information
Review via email: mp+210213@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Thanks for the backup! As you can see, it's a simple workaround (creating a support analytic plan) for avoiding empty values on the line table. BTW, very strange case.

Regards.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks Pedro!

I'm looking at the code and I see that the plan_id was required in the form already in 6.1. Lines could however end up without a plan_id if the plan was deleted. This solution is as good as any. Maybe jot down a note in user_notes.txt that any dangling lines will be linked to a specially created plan by the name of 'OpenUpgrade migration plan'?

review: Needs Information
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I have added the user notes for the module. Thanks for the suggestion.

Regards.

Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'account_analytic_plans/migrations/7.0.1.0/openupgrade_analysis_work.txt'
2--- account_analytic_plans/migrations/7.0.1.0/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000
3+++ account_analytic_plans/migrations/7.0.1.0/openupgrade_analysis_work.txt 2014-03-10 15:37:31 +0000
4@@ -0,0 +1,10 @@
5+---Fields in module 'account_analytic_plans'---
6+account_analytic_plans / account.analytic.plan.line / plan_id (many2one) : now required
7+### -> Created script for filling it for empty values
8+
9+---XML records in module 'account_analytic_plans'---
10+DEL account.journal.column: account.journal_col11
11+DEL ir.actions.act_window: account_analytic_plans.account_analytic_plan_form_action_installer
12+DEL ir.actions.todo: account_analytic_plans.account_analytic_plan_installer_todo
13+### -> Nothing to do
14+
15
16=== added file 'account_analytic_plans/migrations/7.0.1.0/pre-migration.py'
17--- account_analytic_plans/migrations/7.0.1.0/pre-migration.py 1970-01-01 00:00:00 +0000
18+++ account_analytic_plans/migrations/7.0.1.0/pre-migration.py 2014-03-10 15:37:31 +0000
19@@ -0,0 +1,44 @@
20+# -*- coding: utf-8 -*-
21+##############################################################################
22+#
23+# OpenERP, Open Source Management Solution
24+# This migration script copyright (C) 2014
25+# Pedro M. Baeza (pedro.baeza@serviciosbaeza.com)
26+#
27+# This program is free software: you can redistribute it and/or modify
28+# it under the terms of the GNU Affero General Public License as
29+# published by the Free Software Foundation, either version 3 of the
30+# License, or (at your option) any later version.
31+#
32+# This program is distributed in the hope that it will be useful,
33+# but WITHOUT ANY WARRANTY; without even the implied warranty of
34+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35+# GNU Affero General Public License for more details.
36+#
37+# You should have received a copy of the GNU Affero General Public License
38+# along with this program. If not, see <http://www.gnu.org/licenses/>.
39+#
40+##############################################################################
41+from openupgrade import openupgrade
42+
43+@openupgrade.migrate()
44+def migrate(cr, version):
45+ # look for account.analytic.plan.line without plan_id
46+ cr.execute("""
47+ SELECT id
48+ FROM account_analytic_plan_line
49+ WHERE plan_id is NULL""")
50+ record = cr.fetchone()
51+ if record:
52+ # Create support plan
53+ logged_query(cr, ("""
54+ INSERT INTO account_analytic_plan ('name')
55+ FROM account_analytic_plan_line
56+ VALUES ('OpenUpgrade migration plan')""")
57+ # Fill empty values with this new record value
58+ logged_query(cr, ("""
59+ UPDATE account_analytic_plan_line
60+ SET plan_id =
61+ (SELECT id FROM account_analytic_plan
62+ WHERE NAME='OpenUpgrade migration plan')
63+ WHERE plan_id is NULL""")
64
65=== added file 'account_analytic_plans/migrations/7.0.1.0/user_notes.txt'
66--- account_analytic_plans/migrations/7.0.1.0/user_notes.txt 1970-01-01 00:00:00 +0000
67+++ account_analytic_plans/migrations/7.0.1.0/user_notes.txt 2014-03-10 15:37:31 +0000
68@@ -0,0 +1,2 @@
69+1) Any dangling analytic plan line (line without any plan) will be linked to a
70+specially created plan by the name of 'OpenUpgrade migration plan'.

Subscribers

People subscribed via source and target branches