Files
bank-payment/account_payment_order/migrations/9.0.1.0.0/post-migration.py
Pedro M. Baeza c4a230073c [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.
2017-01-06 11:45:31 +01:00

35 lines
908 B
Python

# -*- coding: utf-8 -*-
# © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
def map_payment_type(cr):
openupgrade.map_values(
cr,
'payment_order_type', 'payment_type', [
('payment', 'outbound'),
('debit', 'inbound'),
],
table='account_payment_order', write='sql')
openupgrade.map_values(
cr,
openupgrade.get_legacy_name('state'), 'state',
[('done', 'uploaded')],
table='account_payment_order', write='sql')
@openupgrade.migrate(use_env=True)
def migrate(env, version):
cr = env.cr
map_payment_type(cr)
cr.execute("""
UPDATE account_payment_order apo
SET journal_id=apm.fixed_journal_id
FROM account_payment_mode apm
WHERE apo.payment_mode_id = apm.id
""")