From 3fd770da701cacaffa4e6445dad029dda3fafcd5 Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 4 Dec 2019 17:08:03 +0100 Subject: [PATCH 1/2] [MIG] payment_transfer --- .../migrations/13.0.1.0/noupdate_changes.xml | 8 ++++---- .../13.0.1.0/openupgrade_analysis_work.txt | 11 +++++++++++ .../migrations/13.0.1.0/post-migration.py | 14 ++++++++++++++ .../migrations/13.0.1.0/pre-migration.py | 19 +++++++++++++++++++ .../openupgrade/doc/source/modules120-130.rst | 2 +- 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt create mode 100644 addons/payment_transfer/migrations/13.0.1.0/post-migration.py create mode 100644 addons/payment_transfer/migrations/13.0.1.0/pre-migration.py diff --git a/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml b/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml index fed41f89ecc0..949261443a8e 100644 --- a/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml +++ b/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml @@ -1,10 +1,10 @@ - - - - + + + + Please make a payment to: diff --git a/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt b/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..81e4d97f7468 --- /dev/null +++ b/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,11 @@ +---Models in module 'payment_transfer'--- +---Fields in module 'payment_transfer'--- +payment_transfer / payment.acquirer / provider (False) : selection_keys is now '['adyen', 'alipay', 'authorize', 'buckaroo', 'manual', 'ogone', 'paypal', 'payulatam', 'payumoney', 'sips', 'stripe', 'test', 'transfer']' ('['adyen', 'authorize', 'buckaroo', 'manual', 'ogone', 'paypal', 'payumoney', 'sips', 'stripe', 'transfer']') +# NOTHING TO DO: new option 'alipay' + +---XML records in module 'payment_transfer'--- +ir.ui.view: payment_transfer.transfer_form (noupdate) (noupdate switched) +# DONE: pre-migration: handled noupdate switched + +DEL payment.acquirer: payment.payment_acquirer_custom (noupdate) +# DONE: post-migration: try to delete diff --git a/addons/payment_transfer/migrations/13.0.1.0/post-migration.py b/addons/payment_transfer/migrations/13.0.1.0/post-migration.py new file mode 100644 index 000000000000..16fdb28f7cb0 --- /dev/null +++ b/addons/payment_transfer/migrations/13.0.1.0/post-migration.py @@ -0,0 +1,14 @@ +# Copyright 2020 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data( + env.cr, "payment_transfer", "migrations/13.0.1.0/noupdate_changes.xml") + openupgrade.delete_records_safely_by_xml_id( + env, [ + "payment.payment_acquirer_custom", + ] + ) diff --git a/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py b/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py new file mode 100644 index 000000000000..c3e3c0886091 --- /dev/null +++ b/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py @@ -0,0 +1,19 @@ +# Copyright 2020 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def switch_noupdate_records(env): + openupgrade.set_xml_ids_noupdate_value( + env, + "payment_transfer", + [ + "transfer_form", + ], + True, + ) + + +@openupgrade.migrate() +def migrate(env, version): + switch_noupdate_records(env) diff --git a/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index 98d7f6d72783..3f0d245f0c11 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -487,7 +487,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ | |new| payment_test | | +----------------------------------------------+-------------------------------------------------+ -|payment_transfer | | +|payment_transfer | Done | +----------------------------------------------+-------------------------------------------------+ |phone_validation | Nothing to do | +----------------------------------------------+-------------------------------------------------+ From e0f40d01b126664ab24b0204eb6e46130d338798 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 11 Nov 2020 18:09:18 +0100 Subject: [PATCH 2/2] [FIX] payment_transfer: Finish migration scripts * Don't load noupdate changes that can overwrite user data * Switch noupdate flag on post * Don't try to delete again a record --- .../migrations/13.0.1.0/noupdate_changes.xml | 5 ++--- .../13.0.1.0/openupgrade_analysis_work.txt | 4 ++-- .../migrations/13.0.1.0/post-migration.py | 13 +++++++------ .../migrations/13.0.1.0/pre-migration.py | 19 ------------------- 4 files changed, 11 insertions(+), 30 deletions(-) delete mode 100644 addons/payment_transfer/migrations/13.0.1.0/pre-migration.py diff --git a/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml b/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml index 949261443a8e..dee69490f6fb 100644 --- a/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml +++ b/addons/payment_transfer/migrations/13.0.1.0/noupdate_changes.xml @@ -5,14 +5,13 @@ - - Please make a payment to:
  • Bank: 
  • Account Number:
  • Account Holder:
]]>
- enabled + enabled -->
diff --git a/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt b/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt index 81e4d97f7468..268441a3f750 100644 --- a/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt +++ b/addons/payment_transfer/migrations/13.0.1.0/openupgrade_analysis_work.txt @@ -5,7 +5,7 @@ payment_transfer / payment.acquirer / provider (False) : se ---XML records in module 'payment_transfer'--- ir.ui.view: payment_transfer.transfer_form (noupdate) (noupdate switched) -# DONE: pre-migration: handled noupdate switched +# DONE: post-migration: handled noupdate switched, but after Odoo has updated to current valid definition DEL payment.acquirer: payment.payment_acquirer_custom (noupdate) -# DONE: post-migration: try to delete +# NOTHING TO DO: Already tried to remove on payment diff --git a/addons/payment_transfer/migrations/13.0.1.0/post-migration.py b/addons/payment_transfer/migrations/13.0.1.0/post-migration.py index 16fdb28f7cb0..22b8d6a13075 100644 --- a/addons/payment_transfer/migrations/13.0.1.0/post-migration.py +++ b/addons/payment_transfer/migrations/13.0.1.0/post-migration.py @@ -1,14 +1,15 @@ # Copyright 2020 ForgeFlow +# Copyright 2020 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade @openupgrade.migrate() def migrate(env, version): - openupgrade.load_data( - env.cr, "payment_transfer", "migrations/13.0.1.0/noupdate_changes.xml") - openupgrade.delete_records_safely_by_xml_id( - env, [ - "payment.payment_acquirer_custom", - ] + # We shouldn't load anything from noupdate_changes, as this may be changed + # by users in v12 according their needs + # openupgrade.load_data( + # env.cr, "payment_transfer", "migrations/13.0.1.0/noupdate_changes.xml") + openupgrade.set_xml_ids_noupdate_value( + env, "payment_transfer", ["transfer_form"], True, ) diff --git a/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py b/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py deleted file mode 100644 index c3e3c0886091..000000000000 --- a/addons/payment_transfer/migrations/13.0.1.0/pre-migration.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2020 ForgeFlow -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openupgradelib import openupgrade - - -def switch_noupdate_records(env): - openupgrade.set_xml_ids_noupdate_value( - env, - "payment_transfer", - [ - "transfer_form", - ], - True, - ) - - -@openupgrade.migrate() -def migrate(env, version): - switch_noupdate_records(env)