Skip to content

Commit

Permalink
[ADD] clean_transient_models
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Apr 5, 2024
1 parent d341a6a commit 23c488f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def do_raise(error):
"convert_to_company_dependent",
"cow_templates_mark_if_equal_to_upstream",
"cow_templates_replicate_upstream",
"clean_transient_models",
]


Expand Down Expand Up @@ -3492,3 +3493,23 @@ def cow_templates_replicate_upstream(cr, mark_colname=None):
"""
).format(mark_identifier),
)


def clean_transient_models(env):
"""Clean transient models to prevent possible issues due to
chained data.
To be run at the base post-migration script for having a general scope. Only
assured to work on > v9.
:param env: Environment/pool variable.
"""
for mname in env:
model = env[mname]
if model.is_transient():
try:
with env._cr.savepoint():
model._transient_clean_rows_older_than(0)
env._cr.commit()
except Exception as e:
logger.warning("Failed to clean transient model %s\n%s", model, str(e))

0 comments on commit 23c488f

Please sign in to comment.