Skip to content

Commit f80482b

Browse files
committed
[FIX] records: skip inactive, invalid views in adapt_domains()
Do not fail when the XML parser fails to parse an inactive view. Inactive views are probably abandoned and do not cause immediate errors in the upgraded db, so just skip them when they are invalid. Also, log the view_id before (re)raising a parser exception. This should save some time when manual fixing of invalid (active) views is needed. upg-1171125 closes #13 Signed-off-by: Alvaro Fuentes Suarez (afu) <[email protected]>
1 parent 48bb075 commit f80482b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/util/domains.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ def adapt_domains(cr, model, old, new, adapter=None, skip_inherit=(), force_adap
309309
if column_exists(cr, "ir_ui_view", "arch_db")
310310
else "arch"
311311
)
312-
cr.execute("SELECT id, model FROM ir_ui_view WHERE {} ~ %s".format(arch_db), [match_old])
313-
for view_id, view_model in cr.fetchall():
312+
cr.execute("SELECT id, model, active FROM ir_ui_view WHERE {} ~ %s".format(arch_db), [match_old])
313+
for view_id, view_model, view_active in cr.fetchall():
314314
# Note: active=None is important to not reactivate views!
315315
try:
316316
with suppress(_Skip), edit_view(cr, view_id=view_id, active=None) as view:
@@ -350,10 +350,16 @@ def adapt_domains(cr, model, old, new, adapter=None, skip_inherit=(), force_adap
350350
if not modified:
351351
raise _Skip
352352
except lxml.etree.XMLSyntaxError as e:
353-
if e.msg.startswith("Opening and ending tag mismatch"):
353+
if e.msg.startswith("Opening and ending tag mismatch") or not view_active:
354354
# this view is already wrong, we don't change it
355-
_logger.warning("Skipping domain adpatation for invalid view (id=%s):\n%s", view_id, e.msg)
355+
_logger.warning(
356+
"Skipping domain adaptation for %sinvalid view (id=%s):\n%s",
357+
"" if view_active else "inactive, ",
358+
view_id,
359+
e.msg,
360+
)
356361
continue
362+
_logger.error("Cannot adapt domain of invalid view (id=%s)", view_id) # noqa: TRY400
357363
raise
358364

359365
# adapt domain in dashboards.

0 commit comments

Comments
 (0)