From 11c8e6126f22b4fa5aafabaa47069444336407d0 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 15 Dec 2020 18:48:30 +0100 Subject: [PATCH] [MIG][14.0] Base --- .../base/14.0.1.3/noupdate_changes.xml | 8 +- .../scripts/base/14.0.1.3/post-migrate.py | 10 ++ .../scripts/base/14.0.1.3/pre-migrate.py | 112 ++++++++++++++++ .../base/14.0.1.3/upgrade_analysis_work.txt | 123 ++++++++++++++++++ 4 files changed, 249 insertions(+), 4 deletions(-) create mode 100644 openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py create mode 100644 openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py create mode 100644 openupgrade_scripts/scripts/base/14.0.1.3/upgrade_analysis_work.txt 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 00f094ba3db9..f8e2dfc3f9d4 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 @@ -39,11 +39,11 @@ 1 - + North Macedonia @@ -76,9 +76,9 @@ 1 EIN - + 0 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 new file mode 100644 index 000000000000..dba805f86db3 --- /dev/null +++ b/openupgrade_scripts/scripts/base/14.0.1.3/post-migrate.py @@ -0,0 +1,10 @@ +# Copyright 2020 Odoo Community Association (OCA) +# Copyright 2020 Opener B.V. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + # Load noupdate changes + openupgrade.load_data(env.cr, "base", "14.0.1.3/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 new file mode 100644 index 000000000000..676296830089 --- /dev/null +++ b/openupgrade_scripts/scripts/base/14.0.1.3/pre-migrate.py @@ -0,0 +1,112 @@ +# Copyright 2020 Odoo Community Association (OCA) +# Copyright 2020 Opener B.V. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging + +from openupgradelib import openupgrade + +from odoo import tools + +_logger = logging.getLogger(__name__) + +try: + from odoo.addons.openupgrade_scripts.apriori import merged_modules, renamed_modules +except ImportError: + renamed_modules = {} + merged_modules = {} + _logger.warn( + "You are using openupgrade_framework without having" + " openupgrade_scripts module available." + " The upgrade process will not work properly." + ) + + +xmlid_renames = [ + # Module category renames were not detected by the analyze. These records + # are created on the fly when intializing a new database in + # odoo/modules/db.py + ( + "base.module_category_accounting_expenses", + "base.module_category_human_resources_expenses", + ), + ("base.module_category_discuss", "base.module_category_productivity_discuss"), + ( + "base.module_category_localization_account_charts", + "base.module_category_accounting_localizations_account_charts", + ), + ("base.module_category_marketing_survey", "base.module_category_marketing_surveys"), + ( + "base.module_category_operations_helpdesk", + "base.module_category_services_helpdesk", + ), + ( + "base.module_category_operations_inventory", + "base.module_category_inventory_inventory", + ), + ( + "base.module_category_operations_inventory_delivery", + "base.module_category_inventory_delivery", + ), + ( + "base.module_category_operations_maintenance", + "base.module_category_manufacturing_maintenance", + ), + ( + "base.module_category_operations_project", + "base.module_category_services_project", + ), + ( + "base.module_category_operations_purchase", + "base.module_category_inventory_purchase", + ), + ( + "base.module_category_operations_timesheets", + "base.module_category_services_timesheets", + ), +] + + +@openupgrade.migrate(use_env=False) +def migrate(cr, version): + """ + Don't request an env for the base pre migration as flushing the env in + odoo/modules/registry.py will break on the 'base' module not yet having + been instantiated. + """ + if "openupgrade_framework" not in tools.config["server_wide_modules"]: + logging.error( + "openupgrade_framework is not preloaded. You are highly " + "recommended to run the Odoo with --load=openupgrade_framework " + "when migrating your database." + ) + # Rename xmlids + openupgrade.rename_xmlids(cr, xmlid_renames) + # Update ir_model_data timestamps from obsolete columns + openupgrade.logged_query( + cr, + """ + UPDATE ir_model_data + SET create_date = COALESCE(date_init, create_date), + write_date = COALESCE(date_update, write_date) + WHERE (create_date IS NULL OR write_date IS NULL) AND + (date_init IS NOT NULL OR date_update IS NOT NULL) + """, + ) + # Set default values from odoo/addons/base/data/base_data.sql + cr.execute( + """ ALTER TABLE ir_model_data + ALTER COLUMN create_date + SET DEFAULT NOW() AT TIME ZONE 'UTC', + ALTER COLUMN write_date + SET DEFAULT NOW() AT TIME ZONE 'UTC' + """ + ) + # Perform module renames and merges + openupgrade.update_module_names(cr, renamed_modules.items()) + openupgrade.update_module_names(cr, merged_modules.items(), merge_modules=True) + + # Migrate partners from Fil to Tagalog + # See https://github.com/odoo/odoo/commit/194ed76c5cc9 + openupgrade.logged_query( + cr, "UPDATE res_partner SET lang = 'tl_PH' WHERE lang = 'fil_PH'" + ) diff --git a/openupgrade_scripts/scripts/base/14.0.1.3/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/base/14.0.1.3/upgrade_analysis_work.txt new file mode 100644 index 000000000000..834debe3d12e --- /dev/null +++ b/openupgrade_scripts/scripts/base/14.0.1.3/upgrade_analysis_work.txt @@ -0,0 +1,123 @@ +---Models in module 'base'--- +model base.document.layout (moved to web) [transient] +new model ir.qweb.field.image_url [abstract] +new model res.users.apikeys [sql_view] +new model res.users.apikeys.description [transient] +new model res.users.apikeys.show [abstract] +new model res.users.identitycheck [transient] +# Nothing to do +---Fields in module 'base'--- +base / ir.model / order (char) : NEW required, req_default: function, hasdefault +# Populated during model reflection +base / ir.model.data / date_init (datetime) : DEL +base / ir.model.data / date_update (datetime) : DEL +# Done: migrate values and set defaults from odoo/addons/base/data/base_data.sql +base / ir.model.data / res_id (integer) : relation is now 'model' ('False') [nothing to do] +base / ir.model.data / res_id (integer) : type is now 'many2one_reference' ('integer') +# Syntactic sugar of the Many2oneReference field +base / ir.model.fields / copied (boolean) : now a function +# Nothing to do. Default/onchange method added +base / ir.model.fields / group_expand (boolean) : NEW +# Nothing to do. Exposure of this field level option for manual fields +base / ir.ui.view / model_ids (one2many) : DEL relation: ir.model.data +# Nothing to do. Related mechanism (in get_inheriting_views_arch) now implemented with subquery +base / ir.ui.view / type (selection) : selection_keys is now '['calendar', 'form', 'gantt', 'graph', 'kanban', 'pivot', 'qweb', 'search', 'tree']' ('['calendar', 'diagram', 'form', 'gantt', 'graph', 'kanban', 'pivot', 'qweb', 'search', 'tree']') +# Nothing to do: Related to the removal of unused web_diagram module +base / report.layout / sequence (integer) : NEW hasdefault +# Nothing to do. Value is set when loading the report.layout data records +base / res.company / account_no (char) : DEL +# Nothing to do. Unused field +base / res.country / image (binary) : DEL attachment: True +# Flag image is now rendered from URL, loaded with noupdate data +base / res.country / state_required (boolean) : NEW hasdefault +base / res.country / zip_required (boolean) : NEW hasdefault +# Values loaded with noupdate data +base / res.currency.rate / currency_id (many2one) : now required +# Nothing to do. Expect all records to have a currency. +base / res.lang / flag_image (binary) : NEW attachment: True +# Nothing to do. New option to assign a flag image to a language that is different from the country flag +base / res.partner / barcode (char) : previously in module point_of_sale +# Nothing to do. Barcode can also be used to identify a contact in base. +base / res.partner.bank / active (boolean) : NEW hasdefault +# Done: merged oca/contact/partner_bank_active into base +base / res.users / api_key_ids (one2many) : NEW relation: res.users.apikeys +base / res.users / barcode (char) : previously in module hr +# Nothing to do. See res.partner's barcode field. +---XML records in module 'base'--- +NEW ir.actions.act_window: base.action_apikeys_admin +NEW ir.actions.act_window: base.action_res_users_keys_description +DEL ir.actions.act_window: base.action_base_document_layout_configurator [renamed to web module] +DEL ir.actions.act_window: base.action_partner_employee_form +DEL ir.actions.act_window: base.action_partner_other_form +DEL ir.actions.act_window: base.company_normal_action_tree +NEW ir.model.access: base.access_base_language_export +NEW ir.model.access: base.access_base_language_import +NEW ir.model.access: base.access_base_language_install +NEW ir.model.access: base.access_base_module_uninstall +NEW ir.model.access: base.access_base_module_update +NEW ir.model.access: base.access_base_module_upgrade +NEW ir.model.access: base.access_base_partner_merge_automatic_wizard +NEW ir.model.access: base.access_base_partner_merge_line +NEW ir.model.access: base.access_base_update_translations +NEW ir.model.access: base.access_change_password_user +NEW ir.model.access: base.access_change_password_wizard +NEW ir.model.access: base.access_ir_demo +NEW ir.model.access: base.access_ir_demo_failure +NEW ir.model.access: base.access_ir_demo_failure_wizard +NEW ir.model.access: base.access_ir_property_group_system +NEW ir.model.access: base.access_res_config +NEW ir.model.access: base.access_res_config_installer +NEW ir.model.access: base.access_res_config_settings +NEW ir.model.access: base.access_res_country_group_system +NEW ir.model.access: base.access_res_users_apikeys_access_employee +NEW ir.model.access: base.access_res_users_apikeys_access_portal +NEW ir.model.access: base.access_res_users_apikeys_description_employee +NEW ir.model.access: base.access_res_users_apikeys_description_portal +NEW ir.model.access: base.access_res_users_apikeys_show_employee +NEW ir.model.access: base.access_res_users_identitycheck_employee +NEW ir.model.access: base.access_res_users_identitycheck_portal +NEW ir.model.access: base.access_reset_view_arch_wizard +NEW ir.model.access: base.access_reset_view_arch_wizard_group_system +NEW ir.model.access: base.access_wizard_ir_model_menu_create +DEL ir.model.access: base.access_ir_actions_act_url_all +DEL ir.model.access: base.access_ir_actions_act_window_all +DEL ir.model.access: base.access_ir_actions_act_window_close_all +DEL ir.model.access: base.access_ir_actions_act_window_view_all +DEL ir.model.access: base.access_ir_actions_all +DEL ir.model.access: base.access_ir_actions_report_all +DEL ir.model.access: base.access_ir_actions_server_all +DEL ir.model.access: base.access_ir_property_group_user_manager +DEL ir.model.access: base.access_ir_server_object_lines_all +NEW ir.module.category: base.module_category_accounting (noupdate) +NEW ir.module.category: base.module_category_accounting_localizations (noupdate) +NEW ir.module.category: base.module_category_accounting_localizations_account_charts (noupdate) +NEW ir.module.category: base.module_category_customizations +NEW ir.module.category: base.module_category_inventory (noupdate) +NEW ir.module.category: base.module_category_productivity (noupdate) +NEW ir.module.category: base.module_category_services (noupdate) +NEW ir.module.category: base.module_category_services_helpdesk +DEL ir.module.category: base.module_category_localization (noupdate) +DEL ir.module.category: base.module_category_localization_account_charts +DEL ir.module.category: base.module_category_operations (noupdate) +DEL ir.module.category: base.module_category_operations_helpdesk +NEW ir.module.module: base.module_planning (noupdate) +DEL ir.module.module: base.module_project_forecast (noupdate) +NEW ir.rule: base.api_key_admin (noupdate) +NEW ir.rule: base.api_key_public (noupdate) +NEW ir.rule: base.api_key_user (noupdate) +NEW ir.rule: base.change_password_rule (noupdate) +NEW ir.rule: base.res_users_identity_check (noupdate) +NEW ir.ui.view: base.form_res_users_key_description +NEW ir.ui.view: base.form_res_users_key_show +NEW ir.ui.view: base.identity_check_wizard +NEW ir.ui.view: base.view_apikeys +NEW ir.ui.view: base.view_model_constraint_search +DEL ir.ui.view: base.layout_preview +DEL ir.ui.view: base.view_base_document_layout +DEL ir.ui.view: base.view_menu +DEL ir.ui.view: base.view_partner_short_form +NEW res.country.group: base.sepa_zone (noupdate) +NEW res.groups: base.group_allow_export +NEW res.lang: base.lang_en_IN +DEL res.lang: base.lang_fil +# Done: switch partners to Tagalog