Skip to content

Commit 3bf1060

Browse files
committed
[IMP] specific: check if custom model exists
When a custom model conflicts with a standard one we may choose to write a specific fix, using the `rename_custom_model` util to rename it. However, although unlikely, customers may remove that model in successive upgrade requests, making the call to `rename_model` unnecessary and the extra entry in the migration report wrong. Part-of: #91
1 parent 32e8b77 commit 3bf1060

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/util/specific.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def dispatch_by_dbuuid(cr, version, callbacks):
4747

4848

4949
def rename_custom_model(cr, model_name, new_model_name, custom_module=None, report_details=""):
50+
cr.execute("SELECT 1 FROM ir_model WHERE model = %s", [model_name])
51+
if not cr.rowcount:
52+
_logger.warning("Model %r not found: skip renaming", model_name)
53+
return
54+
5055
rename_model(cr, model_name, new_model_name, rename_table=True)
5156
module_details = " from module '{}'".format(custom_module) if custom_module else ""
5257
add_to_migration_reports(

0 commit comments

Comments
 (0)