Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] payment: Wait for payment methods to be created #4259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions openupgrade_scripts/scripts/payment/15.0.2.0/end-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from openupgradelib import openupgrade


def create_account_payment_method_line(env):
"""
Create account payment method lines from account payment methods

This is placed in 'end-' instead of 'post-' because we need to wait for
other modules to update. For instance payment_adyen creates its
'account.payment.method' object in XML and that is execute after this
module has been migrated. But running this at 'end-' means that we will
have that updated data.
"""
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_payment_method_line (name, sequence,
payment_method_id, journal_id, create_uid, write_uid,
create_date, write_date)
SELECT DISTINCT ON (apm.id, aj.id) apm.name, 10, apm.id, aj.id,
apm.create_uid, apm.write_uid, apm.create_date, apm.write_date
FROM account_payment_method apm
JOIN payment_acquirer pa ON pa.provider = apm.code
JOIN account_journal aj ON aj.type = 'bank' AND aj.id = pa.journal_id
WHERE apm.code NOT IN ('manual', 'check_printing')
""",
)


@openupgrade.migrate()
def migrate(env, version):
create_account_payment_method_line(env)
19 changes: 0 additions & 19 deletions openupgrade_scripts/scripts/payment/15.0.2.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,12 @@ def fill_payment_transaction_partner_state_id(env):
)


def create_account_payment_method_line(env):
# Create account payment method lines from account payment methods
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_payment_method_line (name, sequence,
payment_method_id, journal_id, create_uid, write_uid,
create_date, write_date)
SELECT DISTINCT ON (apm.id, aj.id) apm.name, 10, apm.id, aj.id,
apm.create_uid, apm.write_uid, apm.create_date, apm.write_date
FROM account_payment_method apm
JOIN payment_acquirer pa ON pa.provider = apm.code
JOIN account_journal aj ON aj.type = 'bank' AND aj.id = pa.journal_id
WHERE apm.code NOT IN ('manual', 'check_printing')
""",
)


@openupgrade.migrate()
def migrate(env, version):
fill_payment_adquirer_allow_tokenization(env)
fill_payment_transaction_tokenize(env)
fill_payment_transaction_partner_state_id(env)
fill_payment_transaction_last_state_change(env)
create_account_payment_method_line(env)
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
openupgrade.load_data(env.cr, "payment", "15.0.2.0/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
Expand Down
Loading