Skip to content

Commit 4230096

Browse files
committed
[IMP] specific: check author in rename_custom_module
When plenty of dbs exhibit the same custom (e.g. a `l10n`) module that needs to be renamed, we may use this util in generic scripts. In that case, it becomes paramount to make sure we only rename a specific module by a specific author. Actually, it would be better to do so in specific scripts too. Also, only log when the module has been successfully removed. closes #223 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 5c5b70e commit 4230096

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/util/specific.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def rename_custom_model(cr, model_name, new_model_name, custom_module=None, repo
8181
)
8282

8383

84-
def rename_custom_module(cr, old_module_name, new_module_name, report_details=""):
85-
cr.execute("SELECT 1 FROM ir_module_module WHERE name = %s", [old_module_name])
84+
def rename_custom_module(cr, old_module_name, new_module_name, report_details="", author="%"):
85+
cr.execute("SELECT 1 FROM ir_module_module WHERE name = %s AND author ILIKE %s", [old_module_name, author])
8686
if not cr.rowcount:
87-
_logger.warning("Module %r not found: skip renaming", old_module_name)
8887
return
8988

9089
rename_module(cr, old_module_name, new_module_name)
90+
_logger.warning("Custom module %r renamed to %r", old_module_name, new_module_name)
9191
add_to_migration_reports(
9292
category="Custom modules",
9393
message="The custom module '{old_module_name}' was renamed to '{new_module_name}'. {report_details}".format(

0 commit comments

Comments
 (0)