Skip to content

Commit 6e8249e

Browse files
committed
[IMP] inconsistencies
Affecting many records is likely due to a bad util usage, so we report about it. Let's also avoid flooding the upgrade report. closes #216 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent fe284ec commit 6e8249e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/util/inconsistencies.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def break_recursive_loops(cr, model, field, name_field="name"):
8080
name=SQL(get_value_or_en_translation(cr, table, name_field)),
8181
)
8282
cr.execute(update_query, [tuple(ids)])
83-
bad_data = cr.fetchall()
83+
n_updates = cr.rowcount
84+
_logger.warning("%s records in %s got their %r column unset to break a recursive loop.", n_updates, table, field)
85+
N_UPDATES_IN_REPORT = 20
86+
bad_data = cr.fetchmany(N_UPDATES_IN_REPORT)
8487

8588
query = format_query(
8689
cr,
@@ -102,13 +105,18 @@ def break_recursive_loops(cr, model, field, name_field="name"):
102105
"""
103106
<details>
104107
<summary>
105-
The following {model} were found to be recursive. Their "{field}" field has been reset.
108+
The following {model} were found to be recursive. Their "{field}" field has been reset.{disclaimer}
106109
</summary>
107110
<ul>{li}</ul>
108111
</details>
109112
""".format(
110113
model=html_escape(model_label),
111114
field=html_escape(field_label),
115+
disclaimer=" Find below a list of the first {} (out of {}) affected records.".format(
116+
N_UPDATES_IN_REPORT, n_updates
117+
)
118+
if n_updates > N_UPDATES_IN_REPORT
119+
else "",
112120
li="".join("<li>{}</li>".format(get_anchor_link_to_record(model, id_, name)) for id_, name in bad_data),
113121
),
114122
format="html",

0 commit comments

Comments
 (0)