-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
[17.0][OU-ADD] payment: Migration scripts #4584
base: 17.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 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): | ||
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 payment_token in PaymentToken.search([("payment_method_id", "=", False)]): | ||
payment_token.payment_method_id = ( | ||
PaymentMethod._get_from_code(payment_token.provider_id.code) | ||
or unknown_payment_method | ||
).id | ||
|
||
for transaction in PaymentTransaction.search([("payment_method_id", "=", False)]): | ||
transaction.payment_method_id = ( | ||
PaymentMethod._get_from_code(transaction.provider_id.code) | ||
or unknown_payment_method | ||
).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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
# 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"), | ||
] | ||
|
||
_field_renames = [ | ||
( | ||
"payment.provider", | ||
"payment_provider", | ||
"payment_icon_ids", | ||
"payment_method_ids", | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for this to work we'll also have to rename |
||
] | ||
|
||
_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_fields(env, _field_renames) | ||
openupgrade.rename_xmlids(env.cr, _xmlids_renames) | ||
openupgrade.set_xml_ids_noupdate_value(env, "payment", _noupdate_xmlids, True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we group those by provider_id and do only one write per provider?