[IMP] account_payment_order: Optimize also account_payment_line.payment_type

This commit is contained in:
Pedro M. Baeza
2019-05-27 12:39:44 +02:00
parent 6633da6631
commit 1ffa4034c4
2 changed files with 11 additions and 1 deletions

View File

@@ -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)

View File

@@ -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',