From 1d04f6b2691bbf1f9f47aab4a82783a23383635d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 12 Jun 2015 21:38:31 +0200 Subject: [PATCH] [IMP] mis_builder: migration script to populate new column root_account --- mis_builder/__openerp__.py | 2 +- .../migrations/8.0.0.2/pre-migration.py | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 mis_builder/migrations/8.0.0.2/pre-migration.py diff --git a/mis_builder/__openerp__.py b/mis_builder/__openerp__.py index 417d5033..7d821bc6 100644 --- a/mis_builder/__openerp__.py +++ b/mis_builder/__openerp__.py @@ -24,7 +24,7 @@ { 'name': 'MIS Builder', - 'version': '0.1', + 'version': '0.2', 'category': 'Reporting', 'summary': """ Build 'Management Information System' Reports and Dashboards diff --git a/mis_builder/migrations/8.0.0.2/pre-migration.py b/mis_builder/migrations/8.0.0.2/pre-migration.py new file mode 100644 index 00000000..7db61f48 --- /dev/null +++ b/mis_builder/migrations/8.0.0.2/pre-migration.py @@ -0,0 +1,41 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# mis_builder module for Odoo, Management Information System Builder +# Copyright (C) 2014-2015 ACSONE SA/NV () +# +# This file is a part of mis_builder +# +# mis_builder is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License v3 or later +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# mis_builder 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 v3 or later for more details. +# +# You should have received a copy of the GNU Affero General Public License +# v3 or later along with this program. +# If not, see . +# +############################################################################## + +def migrate(cr, version): + if not version: + return + + cr.execute(""" + ALTER TABLE mis_report_instance + ADD COLUMN root_account INTEGER + """) + cr.execute(""" + UPDATE mis_report_instance + SET root_account = ( + SELECT id FROM account_account + WHERE parent_id IS NULL + AND company_id = mis_report_instance.company_id + LIMIT 1 + ) + """)