diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 952513e7233b..90c95cd89a47 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -144,7 +144,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | |del| fetchmail_outlook | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| fleet | | | +| fleet | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | gamification | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/fleet/16.0.0.1/noupdate_changes.xml b/openupgrade_scripts/scripts/fleet/16.0.0.1/noupdate_changes.xml index 2ef187a8fbf4..197a5705b8b1 100644 --- a/openupgrade_scripts/scripts/fleet/16.0.0.1/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/fleet/16.0.0.1/noupdate_changes.xml @@ -1,5 +1,6 @@ + diff --git a/openupgrade_scripts/scripts/fleet/16.0.0.1/post-migration.py b/openupgrade_scripts/scripts/fleet/16.0.0.1/post-migration.py new file mode 100644 index 000000000000..28e39fce6e58 --- /dev/null +++ b/openupgrade_scripts/scripts/fleet/16.0.0.1/post-migration.py @@ -0,0 +1,8 @@ +# Copyright 2023 Viindoo - Nguyễn Việt Lâm +# 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, "fleet", "16.0.0.1/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/fleet/16.0.0.1/pre-migration.py b/openupgrade_scripts/scripts/fleet/16.0.0.1/pre-migration.py new file mode 100644 index 000000000000..05775508e5e7 --- /dev/null +++ b/openupgrade_scripts/scripts/fleet/16.0.0.1/pre-migration.py @@ -0,0 +1,40 @@ +# Copyright 2023 Viindoo - Nguyễn Việt Lâm +# Copyright 2024 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def _prefill_fleet_vehicle_category_id(env): + openupgrade.logged_query( + env.cr, "ALTER TABLE fleet_vehicle ADD COLUMN IF NOT EXISTS category_id INT4" + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE fleet_vehicle fv + SET category_id = fvm.category_id + FROM fleet_vehicle_model fvm + WHERE fvm.id = fv.model_id AND fvm.category_id IS NOT NULL + """, + ) + + +def _update_fuel_type(env): + for table, column in ( + ("fleet_vehicle", "fuel_type"), + ("fleet_vehicle_model", "default_fuel_type"), + ): + openupgrade.logged_query( + env.cr, + f""" + UPDATE {table} + SET {column} = 'full_hybrid' + WHERE {column} IN ('full_hybrid_gasoline', 'hybrid') + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _prefill_fleet_vehicle_category_id(env) + _update_fuel_type(env) diff --git a/openupgrade_scripts/scripts/fleet/16.0.0.1/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/fleet/16.0.0.1/upgrade_analysis_work.txt new file mode 100644 index 000000000000..1e958389aa35 --- /dev/null +++ b/openupgrade_scripts/scripts/fleet/16.0.0.1/upgrade_analysis_work.txt @@ -0,0 +1,28 @@ +---Models in module 'fleet'--- +---Fields in module 'fleet'--- +fleet / fleet.service.type / _order : _order is now 'name' ('id') +# NOTHING TO DO + +fleet / fleet.vehicle / category_id (many2one) : NEW relation: fleet.vehicle.model.category, hasdefault: compute +# DONE: pre-migration: Pre-create the column and fast-fill it for avoiding both low performance and rewrite a lot of fields, as the compute method is general for a lot of them. + +fleet / fleet.vehicle / fuel_type (selection) : selection_keys is now '['cng', 'diesel', 'electric', 'full_hybrid', 'gasoline', 'hydrogen', 'lpg', 'plug_in_hybrid_diesel', 'plug_in_hybrid_gasoline']' ('['cng', 'diesel', 'electric', 'full_hybrid_gasoline', 'gasoline', 'hybrid', 'hydrogen', 'lpg', 'plug_in_hybrid_diesel', 'plug_in_hybrid_gasoline']') +fleet / fleet.vehicle.model / default_fuel_type (selection) : selection_keys is now '['cng', 'diesel', 'electric', 'full_hybrid', 'gasoline', 'hydrogen', 'lpg', 'plug_in_hybrid_diesel', 'plug_in_hybrid_gasoline']' ('['cng', 'diesel', 'electric', 'full_hybrid_gasoline', 'gasoline', 'hybrid', 'hydrogen', 'lpg', 'plug_in_hybrid_diesel', 'plug_in_hybrid_gasoline']') +# DONE: pre-migration: full_hybrid_gasoline and hybrid is combined into full_hybrid + +fleet / fleet.vehicle / write_off_date (date) : NEW +# NOTHING TO DO: New field + +fleet / fleet.vehicle.log.contract / name (char) : not a function anymore +# NOTHING TO DO: Converted to computed writable + +fleet / fleet.vehicle.log.services / manager_id (many2one) : NEW relation: res.users, isrelated: related, stored +# NOTHING TO DO: Computed efficiently by ORM + +---XML records in module 'fleet'--- +NEW ir.ui.menu: fleet.fleet_models_configuration +NEW ir.ui.menu: fleet.fleet_services_configuration +NEW ir.ui.menu: fleet.fleet_vehicles_configuration +NEW ir.ui.view: fleet.fleet_vehicle_log_services_view_activity +NEW ir.ui.view: fleet.fleet_vehicle_service_types_view_search +# NOTHING TO DO