From 7360be0374303ab2323c704e6e321d0713b68d6c Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Fri, 3 Jul 2026 12:44:14 -0500 Subject: [PATCH] [OU-ADD] base_automation: Migration scripts --- docsource/modules180-190.rst | 2 +- .../19.0.1.0/post-migration.py | 8 +++ .../base_automation/19.0.1.0/pre-migration.py | 56 +++++++++++++++++++ .../19.0.1.0/upgrade_analysis_work.txt | 25 +++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/base_automation/19.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/base_automation/19.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/base_automation/19.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index 710b30ca4e96..f34394b5daca 100644 --- a/docsource/modules180-190.rst +++ b/docsource/modules180-190.rst @@ -76,7 +76,7 @@ Module coverage 18.0 -> 19.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | base_address_extended |Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| base_automation | | | +| base_automation |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | base_geolocalize |Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/base_automation/19.0.1.0/post-migration.py b/openupgrade_scripts/scripts/base_automation/19.0.1.0/post-migration.py new file mode 100644 index 000000000000..1d28452dedc2 --- /dev/null +++ b/openupgrade_scripts/scripts/base_automation/19.0.1.0/post-migration.py @@ -0,0 +1,8 @@ +# Copyright 2026 Tecnativa - Carlos Lopez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data(env, "base_automation", "19.0.1.0/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/base_automation/19.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/base_automation/19.0.1.0/pre-migration.py new file mode 100644 index 000000000000..618f514cbd19 --- /dev/null +++ b/openupgrade_scripts/scripts/base_automation/19.0.1.0/pre-migration.py @@ -0,0 +1,56 @@ +# Copyright 2026 Tecnativa - Carlos Lopez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +from odoo.addons.base_automation.models.base_automation import TIME_TRIGGERS + + +def _precreate_base_automation_trg_date_range_mode(env): + openupgrade.add_columns( + env, + [ + ( + "base.automation", + "trg_date_range_mode", + "selection", + False, + "base_automation", + ) + ], + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE base_automation + SET trg_date_range_mode = NULL + WHERE trigger NOT IN %s + """, + (tuple(TIME_TRIGGERS),), + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE base_automation + SET trg_date_range_mode = CASE + WHEN trg_date_range < 0 THEN 'before' + ELSE 'after' + END + WHERE trigger IN %s + """, + (tuple(TIME_TRIGGERS),), + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE base_automation + SET trg_date_range = ABS(trg_date_range) + WHERE trg_date_range < 0 AND trigger IN %s + """, + (tuple(TIME_TRIGGERS),), + ) + + +@openupgrade.migrate() +def migrate(env, version): + _precreate_base_automation_trg_date_range_mode(env) diff --git a/openupgrade_scripts/scripts/base_automation/19.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/base_automation/19.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..0f655903c9c1 --- /dev/null +++ b/openupgrade_scripts/scripts/base_automation/19.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,25 @@ +---Models in module 'base_automation'--- +---Fields in module 'base_automation'--- +base_automation / base.automation / activity_ids (one2many) : NEW relation: mail.activity +base_automation / base.automation / message_follower_ids (one2many): NEW relation: mail.followers +base_automation / base.automation / message_ids (one2many) : NEW relation: mail.message +base_automation / base.automation / rating_ids (one2many) : NEW relation: rating.rating +base_automation / base.automation / website_message_ids (one2many): NEW relation: mail.message +# NOTHING TO DO: These fields are inherited from the mail.thread and mail.activity.mixin models. + +base_automation / base.automation / previous_domain (char) : NEW hasdefault: default, stored: False +# NOTHING TO DO: New non-stored field used only in _onchange_domain. + +base_automation / base.automation / trg_date_range_mode (selection): NEW selection_keys: ['after', 'before'], hasdefault: compute +# DONE: pre-migration: Pre-created and pre-computed field based on trigger field +# If trg_date_range is negative, it is set to before; otherwise, it is set to after. + +base_automation / ir.actions.server / name (False) : DEL mode: modify +# NOTHING TO DO: The field is now a regular field instead of a computed one, +# but it remains stored, so the existing data is preserved. +# From now on, this field must be filled in explicitly by the user. + +---XML records in module 'base_automation'--- +NEW ir.ui.view: base_automation.view_server_action_form +DEL ir.ui.view: base_automation.ir_actions_server_view_form_automation +# NOTHING TO DO: Handled by ORM