Skip to content

Commit

Permalink
[OU-ADD] payment: migrate to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haumenphai authored and remi-filament committed Oct 11, 2024
1 parent 9a19b66 commit 73e4f05
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| partner_autocomplete | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| payment | | |
| payment |Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| payment_adyen | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
9 changes: 9 additions & 0 deletions openupgrade_scripts/scripts/payment/17.0.2.0/end-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
activated_providers = env["payment.provider"].search([("state", "!=", "disabled")])
activated_providers._activate_default_pms()
31 changes: 31 additions & 0 deletions openupgrade_scripts/scripts/payment/17.0.2.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def _fill_payment_method(env):
PaymentToken = env["payment.token"].with_context(active_test=False)
PaymentTransaction = env["payment.transaction"].with_context(active_test=False)
PaymentMethod = env["payment.method"].with_context(active_test=False)

for payment_token in PaymentToken.search([("payment_method_id", "=", False)]):
payment_token.payment_method_id = (
PaymentMethod._get_from_code(payment_token.provider_id.code)
or payment_token.provider_id.payment_method_ids[:1]
).id

for transaction in PaymentTransaction.search([("payment_method_id", "=", False)]):
transaction.payment_method_id = (
PaymentMethod._get_from_code(transaction.provider_id.code)
or transaction.provider_id.payment_method_ids[:1]
).id


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "payment", "17.0.2.0/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(
env, ["payment.payment_transaction_user_rule"]
)
_fill_payment_method(env)
Loading

0 comments on commit 73e4f05

Please sign in to comment.