Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/util/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ def remove_model(cr, model, drop_table=True, ignore_m2m=()):
if ignore_m2m != "*":
tables = get_m2m_tables(cr, table_of_model(cr, model))
ignore = set(ignore_m2m)
# manual fields handle should be explicitly
if tables:
cr.execute(
"SELECT array_agg(relation_table) FROM ir_model_fields WHERE relation_table IN %s AND state='manual'",
[tuple(tables)],
)
if cr.rowcount:
ignore.update(cr.fetchone()[0] or [])

for table_name in tables:
if table_name in ignore:
_logger.info("remove_model(%r): m2m table %r explicitly ignored", model, table_name)
Expand Down