From 1ffa4034c476a064e7e05fd1c2a1acffc87b338f Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 May 2019 12:39:44 +0200 Subject: [PATCH] [IMP] account_payment_order: Optimize also account_payment_line.payment_type --- .../migrations/9.0.1.0.0/post-migration.py | 10 +++++++++- .../migrations/9.0.1.0.0/pre-migration.py | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/account_payment_order/migrations/9.0.1.0.0/post-migration.py b/account_payment_order/migrations/9.0.1.0.0/post-migration.py index f52f90ded..0100ccbe9 100644 --- a/account_payment_order/migrations/9.0.1.0.0/post-migration.py +++ b/account_payment_order/migrations/9.0.1.0.0/post-migration.py @@ -19,7 +19,7 @@ def map_payment_type(cr): openupgrade.get_legacy_name('state'), 'state', [('done', 'uploaded'), ('sent', 'generated')], table='account_payment_order', write='sql') - # Populate this missing related field + # Populate these missing related fields openupgrade.logged_query( cr, """ UPDATE bank_payment_line bpl @@ -28,6 +28,14 @@ def map_payment_type(cr): FROM account_payment_order apo WHERE bpl.order_id = apo.id""", ) + openupgrade.logged_query( + cr, """ + UPDATE account_payment_line apl + SET payment_type = apo.payment_type, + state = apo.state + FROM account_payment_order apo + WHERE apl.order_id = apo.id""", + ) @openupgrade.migrate(use_env=True) diff --git a/account_payment_order/migrations/9.0.1.0.0/pre-migration.py b/account_payment_order/migrations/9.0.1.0.0/pre-migration.py index 4c4449127..c6f38f802 100644 --- a/account_payment_order/migrations/9.0.1.0.0/pre-migration.py +++ b/account_payment_order/migrations/9.0.1.0.0/pre-migration.py @@ -160,6 +160,8 @@ def populate_computed_fields(env): openupgrade.add_fields(env, [ ('company_currency_id', 'account.payment.order', 'account_payment_order', 'many2one', False, 'account_payment_order'), + ('payment_type', 'account.payment.line', 'account_payment_line', + 'selection', False, 'account_payment_order'), ('partner_id', 'bank.payment.line', 'bank_payment_line', 'many2one', False, 'account_payment_order'), ('payment_type', 'bank.payment.line', 'bank_payment_line',