From c4a230073c9711adff80b74088ee628e1f57cfda Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 6 Jan 2017 11:45:31 +0100 Subject: [PATCH] [FIX] account_payment_order: Migration scripts Migration scripts for account_payment_order must be triggered only on OpenUpgrade migration from v8 to v9, so the version should be 9.0.1.0.0, as there has been other intermediate versions. This commit also removes obsolete migrations scripts. --- .../migrations/8.0.0.3/post-migration.py | 52 ------------------- .../migrations/8.0.0.3/pre-migration.py | 32 ------------ .../migrations/8.0.0.2/post-migration.py | 50 ------------------ .../migrations/8.0.0.2/pre-migration.py | 32 ------------ .../migrations/8.0.0.5/post-migration.py | 13 ----- .../post-migration.py | 0 .../{9.0.1.1.1 => 9.0.1.0.0}/pre-migration.py | 0 7 files changed, 179 deletions(-) delete mode 100644 account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py delete mode 100644 account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py delete mode 100644 account_banking_sepa_direct_debit/migrations/8.0.0.2/post-migration.py delete mode 100644 account_banking_sepa_direct_debit/migrations/8.0.0.2/pre-migration.py delete mode 100644 account_banking_sepa_direct_debit/migrations/8.0.0.5/post-migration.py rename account_payment_order/migrations/{9.0.1.1.1 => 9.0.1.0.0}/post-migration.py (100%) rename account_payment_order/migrations/{9.0.1.1.1 => 9.0.1.0.0}/pre-migration.py (100%) diff --git a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py b/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py deleted file mode 100644 index 333651147..000000000 --- a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - -from openerp import pooler, SUPERUSER_ID - - -def migrate(cr, version): - if not version: - return - - pool = pooler.get_pool(cr.dbname) - cr.execute(''' - SELECT - old_sepa.file, - rel.account_order_id AS payment_order_id, - payment_order.reference - FROM migration_banking_export_sepa old_sepa - LEFT JOIN migration_account_payment_order_sepa_rel rel - ON old_sepa.id=rel.banking_export_sepa_id - LEFT JOIN payment_order ON payment_order.id=rel.account_order_id - ''') - - for sepa_file in cr.dictfetchall(): - if not sepa_file['payment_order_id']: - continue - filename = 'sct_%s.xml' % sepa_file['reference'].replace('/', '-') - pool['ir.attachment'].create( - cr, SUPERUSER_ID, { - 'name': filename, - 'res_id': sepa_file['payment_order_id'], - 'res_model': 'payment.order', - 'datas': str(sepa_file['file']), - }) - return diff --git a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py b/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py deleted file mode 100644 index f1f5f7b0f..000000000 --- a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - - -def migrate(cr, version): - if not version: - return - - cr.execute( - 'ALTER TABLE banking_export_sepa ' - 'RENAME TO migration_banking_export_sepa') - cr.execute( - 'ALTER TABLE account_payment_order_sepa_rel ' - 'RENAME TO migration_account_payment_order_sepa_rel') diff --git a/account_banking_sepa_direct_debit/migrations/8.0.0.2/post-migration.py b/account_banking_sepa_direct_debit/migrations/8.0.0.2/post-migration.py deleted file mode 100644 index dd759cac6..000000000 --- a/account_banking_sepa_direct_debit/migrations/8.0.0.2/post-migration.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - -from openerp import pooler, SUPERUSER_ID - - -def migrate(cr, version): - if not version: - return - - pool = pooler.get_pool(cr.dbname) - cr.execute(''' - SELECT - old_sepa.file, - rel.account_order_id AS payment_order_id, - payment_order.reference - FROM migration_banking_export_sdd old_sepa - LEFT JOIN migration_account_payment_order_sdd_rel rel - ON old_sepa.id=rel.banking_export_sepa_id - LEFT JOIN payment_order ON payment_order.id=rel.account_order_id - ''') - - for sepa_file in cr.dictfetchall(): - filename = 'sdd_%s.xml' % sepa_file['reference'].replace('/', '-') - pool['ir.attachment'].create( - cr, SUPERUSER_ID, { - 'name': filename, - 'res_id': sepa_file['payment_order_id'], - 'res_model': 'payment.order', - 'datas': str(sepa_file['file']), - }) - return diff --git a/account_banking_sepa_direct_debit/migrations/8.0.0.2/pre-migration.py b/account_banking_sepa_direct_debit/migrations/8.0.0.2/pre-migration.py deleted file mode 100644 index 42fa23b0a..000000000 --- a/account_banking_sepa_direct_debit/migrations/8.0.0.2/pre-migration.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - - -def migrate(cr, version): - if not version: - return - - cr.execute( - 'ALTER TABLE banking_export_sdd ' - 'RENAME TO migration_banking_export_sdd') - cr.execute( - 'ALTER TABLE account_payment_order_sdd_rel ' - 'RENAME TO migration_account_payment_order_sdd_rel') diff --git a/account_banking_sepa_direct_debit/migrations/8.0.0.5/post-migration.py b/account_banking_sepa_direct_debit/migrations/8.0.0.5/post-migration.py deleted file mode 100644 index 958a1af7d..000000000 --- a/account_banking_sepa_direct_debit/migrations/8.0.0.5/post-migration.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Sergio Teruel -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - - -def migrate(cr, version): - if not version: - return - - cr.execute(''' - UPDATE account_banking_mandate SET format='sepa' - ''') - return diff --git a/account_payment_order/migrations/9.0.1.1.1/post-migration.py b/account_payment_order/migrations/9.0.1.0.0/post-migration.py similarity index 100% rename from account_payment_order/migrations/9.0.1.1.1/post-migration.py rename to account_payment_order/migrations/9.0.1.0.0/post-migration.py diff --git a/account_payment_order/migrations/9.0.1.1.1/pre-migration.py b/account_payment_order/migrations/9.0.1.0.0/pre-migration.py similarity index 100% rename from account_payment_order/migrations/9.0.1.1.1/pre-migration.py rename to account_payment_order/migrations/9.0.1.0.0/pre-migration.py