From f936c98aca92c4cf91bec9eb347d58306375ee2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Mon, 12 Sep 2022 12:04:13 +0200 Subject: [PATCH] [IMP] convert_field_to_html: be able to avoid spamming query for each row --- openupgradelib/openupgrade.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openupgradelib/openupgrade.py b/openupgradelib/openupgrade.py index a64fc7e1..14143bd9 100644 --- a/openupgradelib/openupgrade.py +++ b/openupgradelib/openupgrade.py @@ -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. @@ -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(