@@ -32,7 +32,7 @@ def make_index_name(table_name, column_name):
32
32
from .exceptions import SleepyDeveloperError
33
33
from .helpers import _dashboard_actions , _validate_model , table_of_model
34
34
from .inherit import for_each_inherit
35
- from .misc import SelfPrintEvalContext , version_gte
35
+ from .misc import SelfPrintEvalContext , log_progress , version_gte
36
36
from .orm import env
37
37
from .pg import (
38
38
alter_column_type ,
@@ -671,6 +671,9 @@ def convert_binary_field_to_attachment(cr, model, field, encoded=True, name_fiel
671
671
field ,
672
672
)
673
673
674
+ cr .execute (format_query (cr , "SELECT count(*) FROM {} WHERE {} IS NOT NULL" , table , field ))
675
+ [count ] = cr .fetchone ()
676
+
674
677
A = env (cr )["ir.attachment" ]
675
678
iter_cur = cr ._cnx .cursor ("fetch_binary" )
676
679
iter_cur .itersize = 1
@@ -683,7 +686,8 @@ def convert_binary_field_to_attachment(cr, model, field, encoded=True, name_fiel
683
686
table = table ,
684
687
)
685
688
)
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 ):
687
691
# we can't save create the attachment with res_model & res_id as it will fail computing
688
692
# `res_name` field for non-loaded models. Store it naked and change it via SQL after.
689
693
data = bytes (data ) # noqa: PLW2901
0 commit comments