-
-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] base: keep translations for null src while upgrade
The method ``update_translatable_fields`` is inspired in the core ``_get_translation_upgrade_queries`` method, which had a bug that has been recently addressed in odoo/odoo#168038 Let's use that core method with openupgradelib so we can be up to date with any further bugfix. TT49615
- Loading branch information
1 parent
2217dfd
commit c90e727
Showing
4 changed files
with
52 additions
and
70 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
openupgrade_scripts/scripts/base/16.0.1.3/end-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,42 @@ | ||
# Copyright 2024 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade, openupgrade_160 | ||
|
||
from odoo.tools import column_exists | ||
|
||
|
||
def update_translatable_fields(env): | ||
"""Update ir.translation records to jsonb column values. We need to do it at the | ||
end as we'll already have all the models in the registry""" | ||
# exclude fields from translation update | ||
exclusions = [ | ||
# ir.actions.* inherits the name and help columns from ir.actions.actions | ||
("ir.actions.act_window", "name"), | ||
("ir.actions.act_window", "help"), | ||
("ir.actions.act_url", "name"), | ||
("ir.actions.act_url", "help"), | ||
("ir.actions.server", "name"), | ||
("ir.actions.server", "help"), | ||
("ir.actions.client", "name"), | ||
("ir.actions.client", "help"), | ||
("ir.actions.report", "name"), | ||
("ir.actions.report", "help"), | ||
] | ||
fields = env["ir.model.fields"].search_read( | ||
[("translate", "=", True)], ["model", "name"] | ||
) | ||
fields_spec = [ | ||
(f["model"], f["name"]) | ||
for f in fields | ||
if ( | ||
(f["model"], f["name"]) not in exclusions | ||
and env.get(f["model"]) | ||
and column_exists(env.cr, env[f["model"]]._table, f["name"]) | ||
) | ||
] | ||
openupgrade_160.migrate_translations_to_jsonb(env, fields_spec) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
update_translatable_fields(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
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
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