Skip to content

Commit

Permalink
[FIX] _convert_field_bootstrap_4to5_sql: Detect json and convert its …
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
hbrunn committed Dec 26, 2023
1 parent fdc1a1a commit 2981518
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit 2981518

Please sign in to comment.