-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] sale_planner_calendar: All wizard lines are updated even if are…
… not modified. Add migration script to remove invalid select valued fields which Odoo has not removed by changing only their value from uppercase to lowercase.
- Loading branch information
1 parent
50dc364
commit 380f7c5
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
sale_planner_calendar/migrations/15.0.2.2.1/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2024 Tecnativa - Carlos Dauden | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _remove_renamed_selection_values(env): | ||
"""After rename value from upper to lower the values are duplicated. | ||
This method removes old upper values""" | ||
week_list_field = env.ref( | ||
"sale_planner_calendar.field_sale_planner_calendar_wizard__week_list" | ||
) | ||
value_ids = week_list_field.selection_ids.filtered(lambda x: x.value.isupper()).ids | ||
if value_ids: | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
DELETE FROM ir_model_fields_selection | ||
WHERE id in %(selection_value_ids)s | ||
""", | ||
{"selection_value_ids": tuple(value_ids)}, | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
_remove_renamed_selection_values(env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters