-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by MiquelRForgeFlow
- Loading branch information
Showing
8 changed files
with
1,050 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() |
405 changes: 405 additions & 0 deletions
405
openupgrade_scripts/scripts/payment/17.0.2.0/noupdate_changes_work.xml
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) | ||
# Copyright 2024 Le Filament (https://le-filament.com) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def _fill_payment_method(env): | ||
PaymentProvider = env["payment.provider"] | ||
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) | ||
|
||
unknown_payment_method = env.ref("payment.payment_method_unknown") | ||
|
||
for group in PaymentToken.read_group( | ||
[("payment_method_id", "=", False)], ["provider_id"], ["provider_id"] | ||
): | ||
provider = PaymentProvider.browse(group["provider_id"][0]) | ||
PaymentToken.search(group["__domain"]).write( | ||
{ | ||
"payment_method_id": ( | ||
PaymentMethod._get_from_code(provider.code) | ||
or unknown_payment_method | ||
).id, | ||
} | ||
) | ||
|
||
for group in PaymentTransaction.read_group( | ||
[("payment_method_id", "=", False)], ["provider_id"], ["provider_id"] | ||
): | ||
provider = PaymentProvider.browse(group["provider_id"][0]) | ||
PaymentTransaction.search(group["__domain"]).write( | ||
{ | ||
"payment_method_id": ( | ||
PaymentMethod._get_from_code(provider.code) | ||
or unknown_payment_method | ||
).id | ||
} | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.load_data(env, "payment", "17.0.2.0/noupdate_changes_work.xml") | ||
openupgrade.delete_records_safely_by_xml_id( | ||
env, ["payment.payment_transaction_user_rule"] | ||
) | ||
_fill_payment_method(env) |
197 changes: 197 additions & 0 deletions
197
openupgrade_scripts/scripts/payment/17.0.2.0/pre-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,197 @@ | ||
# Copyright 2024 Le Filament (https://le-filament.com) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from openupgradelib import openupgrade | ||
|
||
_xmlids_renames = [ | ||
( | ||
"payment.action_payment_icon", | ||
"payment.action_payment_method", | ||
), | ||
( | ||
"payment.payment_icon_cc_visa", | ||
"payment.payment_method_visa", | ||
), | ||
( | ||
"payment.payment_icon_cc_mastercard", | ||
"payment.payment_method_mastercard", | ||
), | ||
( | ||
"payment.payment_icon_cc_american_express", | ||
"payment.payment_method_amex", | ||
), | ||
( | ||
"payment.payment_icon_cc_discover", | ||
"payment.payment_method_discover", | ||
), | ||
( | ||
"payment.payment_icon_cc_diners_club_intl", | ||
"payment.payment_method_diners", | ||
), | ||
( | ||
"payment.payment_icon_paypal", | ||
"payment.payment_method_paypal", | ||
), | ||
( | ||
"payment.payment_icon_cc_rupay", | ||
"payment.payment_method_rupay", | ||
), | ||
# This one has been removed with https://github.com/odoo/odoo/pull/140907 | ||
# ( | ||
# "payment.payment_icon_apple_pay", | ||
# "payment.payment_method_apple_pay", | ||
# ), | ||
( | ||
"payment.payment_icon_cc_jcb", | ||
"payment.payment_method_jcb", | ||
), | ||
( | ||
"payment.payment_icon_cc_maestro", | ||
"payment.payment_method_maestro", | ||
), | ||
( | ||
"payment.payment_icon_cc_cirrus", | ||
"payment.payment_method_cirrus", | ||
), | ||
( | ||
"payment.payment_icon_cc_unionpay", | ||
"payment.payment_method_unionpay", | ||
), | ||
( | ||
"payment.payment_icon_cc_bancontact", | ||
"payment.payment_method_bancontact", | ||
), | ||
# This one has been removed with https://github.com/odoo/odoo/pull/140907 | ||
# ( | ||
# "payment.payment_icon_cc_western_union", | ||
# "payment.payment_method_western_union", | ||
# ), | ||
( | ||
"payment.payment_icon_sepa", | ||
"payment.payment_method_sepa_direct_debit", | ||
), | ||
( | ||
"payment.payment_icon_cc_ideal", | ||
"payment.payment_method_ideal", | ||
), | ||
# This one has been removed with https://github.com/odoo/odoo/pull/120446 | ||
# | ||
# ( | ||
# "payment.payment_icon_cc_webmoney", | ||
# "payment.payment_method_webmoney", | ||
# ), | ||
( | ||
"payment.payment_icon_cc_giropay", | ||
"payment.payment_method_giropay", | ||
), | ||
( | ||
"payment.payment_icon_cc_eps", | ||
"payment.payment_method_eps", | ||
), | ||
( | ||
"payment.payment_icon_cc_p24", | ||
"payment.payment_method_p24", | ||
), | ||
( | ||
"payment.payment_icon_cc_codensa_easy_credit", | ||
"payment.payment_method_codensa", | ||
), | ||
( | ||
"payment.payment_icon_kbc", | ||
"payment.payment_method_kbc_cbc", | ||
), | ||
( | ||
"payment.payment_icon_mpesa", | ||
"payment.payment_method_mpesa", | ||
), | ||
# This one has been removed with https://github.com/odoo/odoo/pull/120446 | ||
# ( | ||
# "payment.payment_icon_airtel_money", | ||
# "payment.payment_method_airtel_money", | ||
# ), | ||
( | ||
"payment.payment_icon_mtn_mobile_money", | ||
"payment.payment_method_mobile_money", | ||
), | ||
( | ||
"payment.payment_icon_barter_by_flutterwave", | ||
"payment.payment_method_ussd", | ||
), | ||
# This one has been removed with https://github.com/odoo/odoo/pull/120446 | ||
# ( | ||
# "payment.payment_icon_sadad", | ||
# "payment.payment_method_sadad", | ||
# ), | ||
( | ||
"payment.payment_icon_mada", | ||
"payment.payment_method_mada", | ||
), | ||
# These ones have been removed with https://github.com/odoo/odoo/pull/120446 | ||
# ( | ||
# "payment.payment_icon_bbva_bancomer", | ||
# "payment.payment_method_bbva_bancomer", | ||
# ), | ||
# ( | ||
# "payment.payment_icon_citibanamex", | ||
# "payment.payment_method_citibanamex", | ||
# ), | ||
] | ||
|
||
_model_renames = [ | ||
("payment.icon", "payment.method"), | ||
] | ||
|
||
_table_renames = [ | ||
("payment_icon", "payment_method"), | ||
("payment_icon_payment_provider_rel", "payment_method_payment_provider_rel"), | ||
] | ||
|
||
_column_renames = { | ||
"payment_method_payment_provider_rel": [ | ||
("payment_icon_id", "payment_method_id"), | ||
], | ||
} | ||
|
||
_field_renames = [ | ||
( | ||
"payment.provider", | ||
"payment_provider", | ||
"payment_icon_ids", | ||
"payment_method_ids", | ||
), | ||
] | ||
|
||
_noupdate_xmlids = [ | ||
"payment_method_visa", | ||
"payment_method_mastercard", | ||
"payment_method_amex", | ||
"payment_method_discover", | ||
"payment_method_diners", | ||
"payment_method_paypal", | ||
"payment_method_rupay", | ||
"payment_method_jcb", | ||
"payment_method_maestro", | ||
"payment_method_cirrus", | ||
"payment_method_unionpay", | ||
"payment_method_bancontact", | ||
"payment_method_sepa_direct_debit", | ||
"payment_method_ideal", | ||
"payment_method_giropay", | ||
"payment_method_eps", | ||
"payment_method_p24", | ||
"payment_method_codensa", | ||
"payment_method_kbc_cbc", | ||
"payment_method_mpesa", | ||
"payment_method_mobile_money", | ||
"payment_method_ussd", | ||
"payment_method_mada", | ||
] | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_models(env.cr, _model_renames) | ||
openupgrade.rename_tables(env.cr, _table_renames) | ||
openupgrade.rename_columns(env.cr, _column_renames) | ||
openupgrade.rename_fields(env, _field_renames) | ||
openupgrade.rename_xmlids(env.cr, _xmlids_renames) | ||
openupgrade.set_xml_ids_noupdate_value(env, "payment", _noupdate_xmlids, True) |
Oops, something went wrong.