@@ -32,7 +32,7 @@ def make_index_name(table_name, column_name):
3232from .exceptions import SleepyDeveloperError
3333from .helpers import _dashboard_actions , _validate_model , table_of_model
3434from .inherit import for_each_inherit
35- from .misc import SelfPrintEvalContext , version_gte
35+ from .misc import SelfPrintEvalContext , log_progress , version_gte
3636from .orm import env
3737from .pg import (
3838 alter_column_type ,
@@ -671,6 +671,9 @@ def convert_binary_field_to_attachment(cr, model, field, encoded=True, name_fiel
671671 field ,
672672 )
673673
674+ cr .execute (format_query (cr , "SELECT count(*) FROM {} WHERE {} IS NOT NULL" , table , field ))
675+ [count ] = cr .fetchone ()
676+
674677 A = env (cr )["ir.attachment" ]
675678 iter_cur = cr ._cnx .cursor ("fetch_binary" )
676679 iter_cur .itersize = 1
@@ -683,7 +686,8 @@ def convert_binary_field_to_attachment(cr, model, field, encoded=True, name_fiel
683686 table = table ,
684687 )
685688 )
686- for rid , data , name in iter_cur :
689+ logger = _logger .getChild ("convert_binary_field_to_attachment" )
690+ for rid , data , name in log_progress (iter_cur , logger = logger , qualifier = "rows" , size = count ):
687691 # we can't save create the attachment with res_model & res_id as it will fail computing
688692 # `res_name` field for non-loaded models. Store it naked and change it via SQL after.
689693 data = bytes (data ) # noqa: PLW2901
0 commit comments