Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] _convert_field_bootstrap_4to5_sql: Detect json and convert its values #357

Merged
Merged
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
11 changes: 10 additions & 1 deletion openupgradelib/openupgrade_160.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from itertools import product

from psycopg2 import sql
from psycopg2.extras import Json

from odoo.tools.translate import _get_translation_upgrade_queries

Expand Down Expand Up @@ -393,7 +394,15 @@ def _convert_field_bootstrap_4to5_sql(cr, table, field, ids=None):
params = (tuple(ids),)
cr.execute(sql.SQL(query).format(**format_query_args), params)
for id_, old_content in cr.fetchall():
new_content = convert_string_bootstrap_4to5(old_content)
if type(old_content) == dict:
new_content = Json(
{
key: convert_string_bootstrap_4to5(value)
for key, value in old_content.items()
}
)
else:
new_content = convert_string_bootstrap_4to5(old_content)
if old_content != new_content:
cr.execute(
sql.SQL("UPDATE {table} SET {field} = %s WHERE id = %s").format(
Expand Down
Loading