Skip to content

Commit 697c7fb

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

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/util/specific.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ def rename_custom_model(cr, model_name, new_model_name, custom_module=None, repo
6363

6464

6565
def rename_custom_module(cr, old_module_name, new_module_name, report_details=""):
66-
rename_module(cr, old_module_name, new_module_name)
66+
cr.execute("SELECT 1 FROM ir_module_module WHERE name = %s", [old_module_name])
67+
if not cr.rowcount:
68+
_logger.warning("Module %r not found: skip renaming", old_module_name)
69+
return
6770

71+
rename_module(cr, old_module_name, new_module_name)
6872
add_to_migration_reports(
6973
category="Custom modules",
7074
message="The custom module '{old_module_name}' was renamed to '{new_module_name}'. {report_details}".format(

0 commit comments

Comments
 (0)