From b4672a34c402fbe79e527fd462b5710bff75d5a5 Mon Sep 17 00:00:00 2001 From: Cyril Sester Date: Fri, 15 Aug 2014 11:38:19 +0200 Subject: [PATCH] Add migration field from 0.1 to 0.2 --- .../__openerp__.py | 2 +- .../migrations/0.2/post-consolidation.py | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 account_banking_sepa_direct_debit/migrations/0.2/post-consolidation.py diff --git a/account_banking_sepa_direct_debit/__openerp__.py b/account_banking_sepa_direct_debit/__openerp__.py index 3d774a34d..30148fb1d 100644 --- a/account_banking_sepa_direct_debit/__openerp__.py +++ b/account_banking_sepa_direct_debit/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Account Banking SEPA Direct Debit', 'summary': 'Create SEPA files for Direct Debit', - 'version': '0.1', + 'version': '0.2', 'license': 'AGPL-3', 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/account_banking_sepa_direct_debit/migrations/0.2/post-consolidation.py b/account_banking_sepa_direct_debit/migrations/0.2/post-consolidation.py new file mode 100644 index 000000000..f183f33cc --- /dev/null +++ b/account_banking_sepa_direct_debit/migrations/0.2/post-consolidation.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Compassion CH () +# +# 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 . +# +############################################################################## + +""" +This script covers the migration of the 0.1 to 0.2 version of sepa mandates. +As table names changed, we want to migrate values from sdd_mandate table to +newly created account_banking_mandate. We also copy foreign keys in invoice +and payment lines. +Finally, we remove useless fields (sdd_mandate_id) and obsolete table +(sdd_mandate). +""" + +__name__ = "account.banking.sepa.direct_debit:: Move sdd_mandate data to account_banking_mandate" + +def migrate(cr, installed_version): + query = "INSERT INTO account_banking_mandate " \ + "SELECT id, create_uid, create_date, write_date, write_uid, " \ + "partner_bank_id, last_debit_date, scan, company_id, state, " \ + "unique_mandate_reference, signature_date, sepa_migrated, " \ + "original_mandate_identification, recurrent_sequence_type, type " \ + "FROM sdd_mandate" + cr.execute(query) + query2 = "UPDATE account_invoice SET mandate_id=sdd_mandate_id" + cr.execute(query2) + query3 = "UPDATE payment_line SET mandate_id=sdd_mandate_id" + cr.execute(query3) + query4 = "ALTER TABLE account_invoice DROP COLUMN IF EXISTS sdd_mandate_id" + cr.execute(query4) + query5 = "ALTER TABLE payment_line DROP COLUMN IF EXISTS sdd_mandate_id" + cr.execute(query5) + query6 = "DROP TABLE IF EXISTS sdd_mandate" + cr.execute(query6)