-
-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Miquel Raïch <[email protected]>
- Loading branch information
1 parent
ace5606
commit 7bded46
Showing
5 changed files
with
166 additions
and
9 deletions.
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
54 changes: 54 additions & 0 deletions
54
addons/payment/migrations/13.0.1.0/openupgrade_analysis_work.txt
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,54 @@ | ||
---Models in module 'payment'--- | ||
new model payment.link.wizard [transient] | ||
# NOTHING TO DO | ||
|
||
---Fields in module 'payment'--- | ||
payment / account.invoice / transaction_ids (many2many) : DEL relation: payment.transaction | ||
payment / account.move / transaction_ids (many2many) : NEW relation: payment.transaction | ||
payment / payment.transaction / invoice_ids (many2many) : relation is now 'account.move' ('account.invoice') [nothing to do] | ||
# DONE: post-migration updated new ids | ||
|
||
payment / payment.acquirer / auth_msg (html) : NEW hasdefault | ||
payment / payment.acquirer / check_validity (boolean) : NEW | ||
payment / payment.acquirer / color (integer) : NEW isfunction: function, stored | ||
payment / payment.acquirer / display_as (char) : NEW | ||
# NOTHING TO DO | ||
|
||
payment / payment.acquirer / environment (selection) : DEL required, selection_keys: ['prod', 'test'], req_default: function | ||
payment / payment.acquirer / state (selection) : NEW required, selection_keys: ['disabled', 'enabled', 'test'], req_default: function, hasdefault | ||
# DONE: Pre-migration renamed to state | ||
|
||
payment / payment.acquirer / image (binary) : DEL attachment: True | ||
payment / payment.acquirer / image_128 (binary) : NEW attachment: True | ||
payment / payment.acquirer / image_medium (binary) : DEL attachment: True | ||
payment / payment.acquirer / image_small (binary) : DEL attachment: True | ||
# DONE: Pre-migration renamed to image_128 | ||
|
||
payment / payment.acquirer / module_state (selection) : is now stored | ||
payment / payment.acquirer / post_msg (html) : DEL | ||
payment / payment.acquirer / specific_countries (boolean) : DEL | ||
payment / payment.acquirer / website_published (boolean) : DEL | ||
payment / payment.acquirer / error_msg (html) : DEL | ||
payment / payment.token / company_id (many2one) : NEW relation: res.company, isrelated: related, stored | ||
# NOTHING TO DO: many2many table didn't changed | ||
|
||
---XML records in module 'payment'--- | ||
NEW ir.actions.act_window: payment.action_invoice_order_generate_link | ||
NEW ir.ui.view: payment.payment_link_wizard_view_form | ||
NEW payment.acquirer: payment.payment_acquirer_alipay (noupdate) | ||
NEW payment.acquirer: payment.payment_acquirer_payulatam (noupdate) | ||
NEW payment.acquirer: payment.payment_acquirer_sepa_direct_debit (noupdate) | ||
NEW payment.icon: payment.payment_icon_cc_codensa_easy_credit | ||
NEW payment.icon: payment.payment_icon_cc_ideal | ||
NEW payment.icon: payment.payment_icon_cc_webmoney | ||
NEW payment.icon: payment.payment_icon_cc_western_union | ||
DEL ir.ui.menu: payment.root_payment_menu [renamed to account module] | ||
DEL ir.ui.view: payment.view_account_payment_invoice_form_inherit_payment | ||
# NOTHING TO DO | ||
|
||
DEL payment.acquirer: payment.payment_acquirer_custom (noupdate) | ||
# DONE: Post-migration | ||
|
||
NEW payment.acquirer: payment.payment_acquirer_ingenico (noupdate) | ||
DEL payment.acquirer: payment.payment_acquirer_ogone (noupdate) | ||
# DONE: Pre-migrations renamed |
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,39 @@ | ||
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
unlink_by_xmlid = [ | ||
'payment.payment_acquirer_custom' | ||
] | ||
|
||
|
||
def map_payment_acquirer_state(cr): | ||
openupgrade.logged_query( | ||
cr, """ | ||
UPDATE payment_acquirer | ||
SET state = CASE WHEN {website_published} = TRUE THEN 'enabled' | ||
ELSE 'disabled' END | ||
WHERE state = 'prod'""".format( | ||
website_published=openupgrade.get_legacy_name('website_published') | ||
) | ||
) | ||
|
||
|
||
def update_account_invoice_transaction_rel_table(cr): | ||
openupgrade.logged_query( | ||
cr, """ | ||
UPDATE account_invoice_transaction_rel aitr | ||
SET invoice_id = am.id | ||
FROM account_move am | ||
WHERE am.old_invoice_id = aitr.{} | ||
""".format(openupgrade.get_legacy_name('invoice_id')) | ||
) | ||
|
||
|
||
@openupgrade.migrate(use_env=True) | ||
def migrate(env, version): | ||
map_payment_acquirer_state(env.cr) | ||
update_account_invoice_transaction_rel_table(env.cr) | ||
openupgrade.delete_records_safely_by_xml_id(env, unlink_by_xmlid) | ||
openupgrade.load_data(env.cr, 'payment', 'migrations/13.0.1.0/noupdate_changes.xml') |
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,44 @@ | ||
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_column_copies = { | ||
'account_invoice_transaction_rel': [ | ||
('invoice_id', None, None), | ||
], | ||
|
||
} | ||
|
||
_column_renames = { | ||
'payment_acquirer': [ | ||
('website_published', None), | ||
], | ||
|
||
} | ||
|
||
_field_renames = [ | ||
('payment.acquirer', 'payment_acquirer', 'image_medium', 'image_128'), | ||
('payment.acquirer', 'payment_acquirer', 'environment', 'state'), | ||
] | ||
|
||
_xmlid_renames = [ | ||
('payment.payment_acquirer_ogone', 'payment.payment_acquirer_ingenico'), | ||
] | ||
|
||
|
||
@openupgrade.migrate(use_env=True) | ||
def migrate(env, version): | ||
openupgrade.rename_fields(env, _field_renames) | ||
openupgrade.copy_columns(env.cr, _column_copies) | ||
openupgrade.rename_columns(env.cr, _column_renames) | ||
openupgrade.rename_xmlids(env.cr, _xmlid_renames) | ||
# Fix image of payment.acquirer after renaming column to image_128 | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE ir_attachment | ||
SET res_field = 'image_128' | ||
WHERE res_field = 'image_medium' and res_model = 'payment.acquirer' | ||
""", | ||
) |
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