-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
Showing
2 changed files
with
644 additions
and
0 deletions.
There are no files selected for viewing
227 changes: 227 additions & 0 deletions
227
openupgrade_scripts/scripts/payment/16.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,227 @@ | ||
# Copyright 2023 Coop IT Easy SC | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_model_renames = [ | ||
("payment.acquirer", "payment.provider"), | ||
] | ||
|
||
_table_renames = [ | ||
("payment_acquirer", "payment_provider"), | ||
("payment_acquirer_payment_icon_rel", "payment_provider_payment_icon_rel"), | ||
] | ||
|
||
_field_moves = [ | ||
{ | ||
"model": "account.bank.statement.line", | ||
"moved_fields": [ | ||
"amount_paid", | ||
"authorized_transaction_ids", | ||
"transaction_ids", | ||
"payment_acquirer_id", | ||
"payment_acquirer_state", | ||
], | ||
"old_module": "payment", | ||
"new_module": "account_payment", | ||
}, | ||
{ | ||
"model": "account.move", | ||
"moved_fields": [ | ||
"amount_paid", | ||
"authorized_transaction_ids", | ||
"transaction_ids", | ||
], | ||
"old_module": "payment", | ||
"new_module": "account_payment", | ||
}, | ||
{ | ||
"model": "account.payment", | ||
"moved_fields": [ | ||
"amount_available_for_refund", | ||
"amount_paid", | ||
"authorized_transaction_ids", | ||
"payment_token_id", | ||
"payment_transaction_id", | ||
"refunds_count", | ||
"source_payment_id", | ||
"suitable_payment_token_ids", | ||
"transaction_ids", | ||
"use_electronic_payment_method", | ||
], | ||
"old_module": "payment", | ||
"new_module": "account_payment", | ||
}, | ||
{ | ||
"model": "payment.transaction", | ||
"moved_fields": [ | ||
"invoice_ids", | ||
"invoices_count", | ||
"payment_id", | ||
], | ||
"old_module": "payment", | ||
"new_module": "account_payment", | ||
}, | ||
] | ||
|
||
_field_renames = [ | ||
( | ||
"account.payment.method.line", | ||
"account_payment_method_line", | ||
"payment_acquirer_id", | ||
"payment_provider_id", | ||
), | ||
( | ||
"account.payment.method.line", | ||
"account_payment_method_line", | ||
"payment_acquirer_state", | ||
"payment_provider_state", | ||
), | ||
( | ||
"payment.icon", | ||
"payment_icon", | ||
"acquirer_ids", | ||
"provider_ids", | ||
), | ||
( | ||
"payment.token", | ||
"payment_token", | ||
"acquirer_id", | ||
"provider_id", | ||
), | ||
( | ||
"payment.token", | ||
"payment_token", | ||
"acquirer_ref", | ||
"provider_ref", | ||
), | ||
( | ||
"payment.token", | ||
"payment_token", | ||
"name", | ||
"payment_details", | ||
), | ||
( | ||
"payment.transaction", | ||
"payment_transaction", | ||
"acquirer_id", | ||
"provider_id", | ||
), | ||
( | ||
"payment.transaction", | ||
"payment_transaction", | ||
"acquirer_reference", | ||
"provider_reference", | ||
), | ||
( | ||
"res.company", | ||
"res_company", | ||
"payment_acquirer_onboarding_state", | ||
"payment_provider_onboarding_state", | ||
), | ||
] | ||
|
||
_xmlid_renames = [ | ||
( | ||
"payment.action_invoice_order_generate_link", | ||
"account_payment.action_invoice_order_generate_link", | ||
), | ||
( | ||
"payment.action_payment_acquirer", | ||
"payment.action_payment_provider", | ||
), | ||
( | ||
"payment.payment_acquirer_onboarding_wizard", | ||
"payment.payment_provider_onboarding_wizard", | ||
), | ||
( | ||
"payment.payment_acquirer_system", | ||
"payment.payment_provider_system", | ||
), | ||
( | ||
"payment.payment_link_wizard", | ||
"account_payment.payment_link_wizard", | ||
), | ||
( | ||
"payment.payment_refund_wizard", | ||
"account_payment.payment_refund_wizard", | ||
), | ||
( | ||
"payment.payment_acquirer_company_rule", | ||
"payment.payment_provider_company_rule", | ||
), | ||
( | ||
"payment.payment_token_billing_rule", | ||
"account_payment.payment_token_billing_rule", | ||
), | ||
( | ||
"payment.payment_transaction_billing_rule", | ||
"account_payment.payment_transaction_billing_rule", | ||
), | ||
( | ||
"payment.payment_acquirer_menu", | ||
"account_payment.payment_provider_menu", | ||
), | ||
( | ||
"payment.payment_icon_menu", | ||
"account_payment.payment_icon_menu", | ||
), | ||
( | ||
"payment.payment_token_menu", | ||
"account_payment.payment_token_menu", | ||
), | ||
( | ||
"payment.payment_transaction_menu", | ||
"account_payment.payment_transaction_menu", | ||
), | ||
( | ||
"payment.account_invoice_view_form_inherit_payment", | ||
"account_payment.account_invoice_view_form_inherit_payment", | ||
), | ||
( | ||
"payment.payment_acquirer_form", | ||
"account_payment.payment_provider_form", | ||
), | ||
( | ||
"payment.payment_acquirer_kanban", | ||
"account_payment.payment_provider_kanban", | ||
), | ||
( | ||
"payment.payment_acquirer_list", | ||
"account_payment.payment_provider_list", | ||
), | ||
( | ||
"payment.payment_acquirer_onboarding_wizard_form", | ||
"payment.payment_provider_onboarding_wizard_form", | ||
), | ||
( | ||
"payment.payment_acquirer_search", | ||
"account_payment.payment_provider_search", | ||
), | ||
( | ||
"payment.payment_refund_wizard_view_form", | ||
"account_payment.payment_refund_wizard_view_form", | ||
), | ||
( | ||
"payment.view_account_journal_form", | ||
"account_payment.view_account_journal_form", | ||
), | ||
( | ||
"payment.view_account_payment_form_inherit_payment", | ||
"account_payment.view_account_payment_form_inherit_payment", | ||
), | ||
( | ||
"payment.view_account_payment_register_form_inherit_payment", | ||
"account_payment.view_account_payment_register_form_inherit_payment", | ||
), | ||
] | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_models(env.cr, _model_renames) | ||
openupgrade.rename_tables(env.cr, _table_renames) | ||
for field_move_args in _field_moves: | ||
openupgrade.update_module_moved_fields(env.cr, **field_move_args) | ||
openupgrade.rename_fields(env.cr, _field_renames) | ||
openupgrade.rename_xmlids(env.cr, _xmlid_renames) |
Oops, something went wrong.