Skip to content

Commit

Permalink
Merge pull request #4655 from Tecnativa/17.0-ou_fix-calendar
Browse files Browse the repository at this point in the history
[17.0][OU-FIX] calendar: Reset sequence field in resource.calendar.attendance
  • Loading branch information
pedrobaeza authored Nov 7, 2024
2 parents c7da00f + 5fea65b commit a78cb37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions openupgrade_scripts/scripts/resource/17.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# Copyright 2024 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


def _reset_calendar_attendance_sequence(env):
"""As the field `sequence` exists previously in 16, and you were able to change it
on screen, there's a chance that your DB have some sequence values that alters the
previous order when migrating.
Thus, the safest thing is to reset the sequence value to its default value for
preserving always the previous order.
"""
openupgrade.logged_query(
env.cr, "UPDATE resource_calendar_attendance SET sequence = 10"
)


@openupgrade.migrate()
def migrate(env, version):
_reset_calendar_attendance_sequence(env)
openupgrade.set_xml_ids_noupdate_value(
env,
"resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource / resource.calendar / hours_per_day (float) : now a
# Nothing To Do, compute non-stored

resource / resource.calendar.attendance / _order : _order is now 'sequence, week_type, dayofweek, hour_from' ('week_type, dayofweek, hour_from')
# Nothing To Do, default order when search
# DONE: pre-migration: Reset the sequence field to its default value for preserving the order.

resource / resource.calendar.attendance / day_period (selection) : selection_keys is now '['afternoon', 'lunch', 'morning']' ('['afternoon', 'morning']')
# Nothing To Do, new option: lunch
Expand Down

0 comments on commit a78cb37

Please sign in to comment.