From d26b0ff20d886499786973903746be242440ed0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 6 Nov 2024 14:11:28 +0100 Subject: [PATCH] [OU-ADD] maintenance: Migration to 17.0 TT50085 --- docsource/modules160-170.rst | 2 +- .../maintenance/17.0.1.0/post-migration.py | 8 +++++ .../maintenance/17.0.1.0/pre-migration.py | 36 +++++++++++++++++++ .../17.0.1.0/upgrade_analysis_work.txt | 36 +++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/maintenance/17.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/maintenance/17.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/maintenance/17.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst index 98e6778dc37d..58b2ad9560ee 100644 --- a/docsource/modules160-170.rst +++ b/docsource/modules160-170.rst @@ -530,7 +530,7 @@ Module coverage 16.0 -> 17.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | mail_plugin | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| maintenance | | | +| maintenance | Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | mass_mailing | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/maintenance/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/maintenance/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..b73b4f7fbf9c --- /dev/null +++ b/openupgrade_scripts/scripts/maintenance/17.0.1.0/post-migration.py @@ -0,0 +1,8 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# 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, "maintenance", "17.0.1.0/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/maintenance/17.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/maintenance/17.0.1.0/pre-migration.py new file mode 100644 index 000000000000..7784c19abf67 --- /dev/null +++ b/openupgrade_scripts/scripts/maintenance/17.0.1.0/pre-migration.py @@ -0,0 +1,36 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def _maintenance_request_company_id(env): + """We set the company_id value for requests that do not have it. + We get the value of what will be deductively most appropriate (equipment, team or + user). + """ + openupgrade.logged_query( + env.cr, + """UPDATE maintenance_request AS request + SET company_id = equipment.company_id + FROM maintenance_equipment AS equipment + WHERE request.company_id IS NULL AND request.equipment_id IS NOT NULL""", + ) + openupgrade.logged_query( + env.cr, + """UPDATE maintenance_request AS request + SET company_id = team.company_id + FROM maintenance_team AS team + WHERE request.company_id IS NULL AND request.maintenance_team_id IS NOT NULL""", + ) + openupgrade.logged_query( + env.cr, + """UPDATE maintenance_request AS request + SET company_id = u.company_id + FROM res_users AS u + WHERE request.company_id IS NULL AND request.user_id IS NOT NULL""", + ) + + +@openupgrade.migrate() +def migrate(env, version): + _maintenance_request_company_id(env) diff --git a/openupgrade_scripts/scripts/maintenance/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/maintenance/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..f6e06376fd34 --- /dev/null +++ b/openupgrade_scripts/scripts/maintenance/17.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,36 @@ +---Models in module 'maintenance'--- +new model maintenance.mixin [abstract] +---Fields in module 'maintenance'--- +maintenance / maintenance.equipment / activity_user_id (many2one) : not related anymore +maintenance / maintenance.equipment / activity_user_id (many2one) : now a function +maintenance / maintenance.equipment / expected_mtbf (integer) : NEW +maintenance / maintenance.equipment / maintenance_duration (float) : DEL +maintenance / maintenance.equipment / message_main_attachment_id (many2one): DEL relation: ir.attachment +maintenance / maintenance.equipment / next_action_date (date) : DEL +maintenance / maintenance.equipment / period (integer) : DEL +maintenance / maintenance.equipment.category / message_main_attachment_id (many2one): DEL relation: ir.attachment +maintenance / maintenance.request / activity_user_id (many2one) : not related anymore +maintenance / maintenance.request / activity_user_id (many2one) : now a function +# NOTHING TO DO +maintenance / maintenance.request / company_id (many2one) : now required +# DONE: pre-migration: Define the most appropriate value +maintenance / maintenance.request / instruction_google_slide (char): NEW +maintenance / maintenance.request / instruction_pdf (binary) : NEW attachment: True +maintenance / maintenance.request / instruction_text (html) : NEW +maintenance / maintenance.request / instruction_type (selection) : NEW selection_keys: ['google_slide', 'pdf', 'text'], hasdefault: default +maintenance / maintenance.request / message_main_attachment_id (many2one): DEL relation: ir.attachment +# NOTHING TO DO +maintenance / maintenance.request / recurring_maintenance (boolean): NEW hasdefault: compute +# Pending +maintenance / maintenance.request / repeat_interval (integer) : NEW hasdefault: default +maintenance / maintenance.request / repeat_type (selection) : NEW selection_keys: ['forever', 'until'], hasdefault: default +maintenance / maintenance.request / repeat_unit (selection) : NEW selection_keys: ['day', 'month', 'week', 'year'], hasdefault: default +maintenance / maintenance.request / repeat_until (date) : NEW +# NOTHING TO DO +---XML records in module 'maintenance'--- +NEW ir.actions.act_window: maintenance.action_maintenance_configuration +DEL ir.cron: maintenance.maintenance_requests_cron +NEW ir.ui.menu: maintenance.menu_maintenance_config +NEW ir.ui.view: maintenance.maintenance_request_view_activity +NEW ir.ui.view: maintenance.res_config_settings_view_form +DEL mail.alias: maintenance.mail_alias_equipment (noupdate)