From 7b3b528ca3f083424407bd0f374f090c453bf976 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Albert Date: Sat, 10 Dec 2016 00:45:31 +0100 Subject: [PATCH] [9.0][MIG]account_banking_mandate: Scritp migration to v9 --- .../migrations/9.0.1.0.0/post-migration.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 account_banking_mandate/migrations/9.0.1.0.0/post-migration.py diff --git a/account_banking_mandate/migrations/9.0.1.0.0/post-migration.py b/account_banking_mandate/migrations/9.0.1.0.0/post-migration.py new file mode 100644 index 000000000..59bc207fe --- /dev/null +++ b/account_banking_mandate/migrations/9.0.1.0.0/post-migration.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# © 2016 Sergio Teruel +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openupgradelib import openupgrade + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + # Copy mandate_id to account_move_line + sql = """ + UPDATE account_move_line aml + SET mandate_id = ai.mandate_id + FROM account_invoice ai + WHERE aml.invoice_id=ai.id + AND aml.invoice_id is not null + AND ai.mandate_id is not null; + """ + openupgrade.logged_query(env.cr, sql)