Skip to content

Commit

Permalink
Merge pull request #304 from ForgeFlow/master-imp-convert_field_to_html
Browse files Browse the repository at this point in the history
[IMP] convert_field_to_html: be ablet to avoid spamming query for each row
  • Loading branch information
MiquelRForgeFlow authored Sep 12, 2022
2 parents d5cbbdd + f936c98 commit f97bf37
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,8 @@ def default_func(cr, pool, id, vals):
{field_new_model: value})


def convert_field_to_html(cr, table, field_name, html_field_name):
def convert_field_to_html(
cr, table, field_name, html_field_name, verbose=True):
"""
Convert field value to HTML value.

Expand All @@ -2195,12 +2196,14 @@ def convert_field_to_html(cr, table, field_name, html_field_name):
}
)
for row in cr.fetchall():
logged_query(
cr, "UPDATE %(table)s SET %(field)s = %%s WHERE id = %%s" % {
'field': html_field_name,
'table': table,
}, (plaintext2html(row[1]), row[0])
)
query = "UPDATE %(table)s SET %(field)s = %%s WHERE id = %%s" % {
'field': html_field_name,
'table': table,
}
if verbose:
logged_query(cr, query, (plaintext2html(row[1]), row[0]))
else:
cr.execute(query, (plaintext2html(row[1]), row[0]))


def date_to_datetime_tz(
Expand Down

0 comments on commit f97bf37

Please sign in to comment.