Skip to content

Commit

Permalink
Merge pull request #337 from duong77476/master_fix_delete_record_tran…
Browse files Browse the repository at this point in the history
…slation

[FIX] delete_record_translations: error when only update for 1 one column
  • Loading branch information
MiquelRForgeFlow authored Jul 6, 2023
2 parents 9599992 + 86aca62 commit ea53875
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2680,18 +2680,20 @@ def delete_record_translations(cr, module, xml_ids, field_list=None):
list_columns.pop(i)
if not list_columns:
continue
columns = ", ".join(list_columns)
values = ", ".join(
"jsonb_build_object('en_US', {x} -> 'en_US')".format(x=x)
for x in list_columns
)
if len(list_columns) > 1:
columns = "({})".format(columns)
values = "({})".format(values)
query = """
UPDATE {table}
SET ({columns}) = ({values})
WHERE id = %s""".format(
table=table,
columns=", ".join(list_columns),
values=", ".join(
[
"jsonb_build_object('en_US', {x} -> 'en_US')".format(x=x)
for x in list_columns
]
),
SET {columns} = {values}
WHERE id = %s
""".format(
table=table, columns=columns, values=values
)
logged_query(cr, query, (record_id,))

Expand Down

0 comments on commit ea53875

Please sign in to comment.