Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| event_sms | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| fleet | Nothing to do | |
| fleet | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| gamification | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
21 changes: 21 additions & 0 deletions openupgrade_scripts/scripts/fleet/17.0.0.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


def _compute_image_128(env):
"""The vehicle models and the vehicles now inherit avatar.mixin, so their
image_128, related to the brand image, is now stored as an attachment, which is
not computed when the field is created. Compute it, the models first, as the
vehicle image is the one of its model.
"""
for model_name in ("fleet.vehicle.model", "fleet.vehicle"):
records = env[model_name].with_context(active_test=False).search([])
env.add_to_compute(records._fields["image_128"], records)
records._recompute_recordset(["image_128"])


@openupgrade.migrate()
def migrate(env, version):
_compute_image_128(env)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fleet / fleet.vehicle / activity_user_id (many2one) : not re
fleet / fleet.vehicle / activity_user_id (many2one) : now a function
fleet / fleet.vehicle / image_1024 (binary) : NEW attachment: True, isrelated: related, stored
fleet / fleet.vehicle / image_128 (binary) : is now stored
# DONE: post-migration: computed, as an attachment field is not computed when it becomes stored
fleet / fleet.vehicle / image_1920 (binary) : NEW attachment: True
fleet / fleet.vehicle / image_256 (binary) : NEW attachment: True, isrelated: related, stored
fleet / fleet.vehicle / image_512 (binary) : NEW attachment: True, isrelated: related, stored
Expand All @@ -20,6 +21,7 @@ fleet / fleet.vehicle.log.services / message_main_attachment_id (many2one
# NOTHING TO DO
fleet / fleet.vehicle.model / image_1024 (binary) : NEW attachment: True, isrelated: related, stored
fleet / fleet.vehicle.model / image_128 (binary) : is now stored
# DONE: post-migration: computed, as an attachment field is not computed when it becomes stored
fleet / fleet.vehicle.model / image_1920 (binary) : NEW attachment: True
fleet / fleet.vehicle.model / image_256 (binary) : NEW attachment: True, isrelated: related, stored
fleet / fleet.vehicle.model / image_512 (binary) : NEW attachment: True, isrelated: related, stored
Expand Down
Loading