From 2caa543f0959df48bd35b2d569538e359e5b06d7 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 5 Jun 2024 11:32:30 +0200 Subject: [PATCH] [OU-ADD] base: web_disable_export_group migration Take the users from the web_disable_export_group.group_export_data group to the new base.group_allow_export which covers the same features. As now Odoo supports disabling data exports, which is the main feature that the module web_disable_export_group provided we want to move the existing users in that module's groups to the new core one. The module's functionality isn't completly merged into core as it allows to differentiate which type of export users can use. This might be unnecessary for some module users that would drop the module while others might want to keep it. To make the transition transparent for both cases, we put this migration script here. TT49468 --- .../group_allow_export_noupdate_changes.xml | 9 ++++++++ .../base/14.0.1.3/noupdate_changes.xml | 10 ++++++--- .../scripts/base/14.0.1.3/post-migrate.py | 7 ++++++ .../scripts/base/14.0.1.3/pre-migrate.py | 22 +++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 openupgrade_scripts/scripts/base/14.0.1.3/group_allow_export_noupdate_changes.xml diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/group_allow_export_noupdate_changes.xml b/openupgrade_scripts/scripts/base/14.0.1.3/group_allow_export_noupdate_changes.xml new file mode 100644 index 000000000000..5fb4d9357c17 --- /dev/null +++ b/openupgrade_scripts/scripts/base/14.0.1.3/group_allow_export_noupdate_changes.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/noupdate_changes.xml b/openupgrade_scripts/scripts/base/14.0.1.3/noupdate_changes.xml index 48ad83b11a68..c4bc9e924d04 100644 --- a/openupgrade_scripts/scripts/base/14.0.1.3/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/base/14.0.1.3/noupdate_changes.xml @@ -22,9 +22,13 @@ 1 - - - + + diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py b/openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py index 448393bb312e..a1369b06e473 100644 --- a/openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py +++ b/openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py @@ -143,3 +143,10 @@ def migrate(env, version): binary_conversion_for_db_attachments(env) # Load noupdate changes openupgrade.load_data(env.cr, "base", "14.0.1.3/noupdate_changes.xml") + # By default Odoo grants new users export access. If we had web_disable_export_group + # installed is very likely that this isn't the desired behavior and that we want + # to keep the access to that feature restricted by default. + if not openupgrade.is_module_installed(env.cr, "web_disable_export_group"): + openupgrade.load_data( + env.cr, "base", "14.0.1.3/group_allow_export_noupdate_changes.xml" + ) diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py b/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py index 6d6b4f9781f5..0c5e41ea276c 100644 --- a/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py +++ b/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py @@ -155,3 +155,25 @@ def migrate(cr, version): cr, "UPDATE res_partner SET lang = 'tl_PH' WHERE lang = 'fil_PH'" ) deduplicate_ir_properties(cr) + # Now Odoo supports disabling data exports, which is the main feature that + # the module web_disable_export_group provided. Although the module isn't completly + # merged into core as it allows to differentiate which type of export users can use. + # This might be unnecessary for some module users that would drop the module while + # others might want to keep it. To make the transition transparent for both cases, + # we put this migration script here. + cr.execute( + """ + SELECT id FROM ir_model_data + WHERE module='web_disable_export_group' AND name='group_export_data' + """ + ) + if cr.fetchone(): + openupgrade.rename_xmlids( + cr, + [ + ( + "web_disable_export_group.group_export_data", + "base.group_allow_export", + ) + ], + )