-
-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a19b66
commit 73e4f05
Showing
4 changed files
with
379 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
openupgrade_scripts/scripts/payment/17.0.2.0/end-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
31
openupgrade_scripts/scripts/payment/17.0.2.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.