Skip to content

Commit 630a1ef

Browse files
committed
[FIX] rename_model: don't rename table to itself
When renaming a model, it may happen that the table stay the same when underscores are replaced by dots. closes #120 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent ea250d0 commit 630a1ef

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/util/models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,10 @@ def rename_model(cr, old, new, rename_table=True):
232232
if old in ENVIRON["__renamed_fields"]:
233233
ENVIRON["__renamed_fields"][new] = ENVIRON["__renamed_fields"].pop(old)
234234
if rename_table:
235-
pg_rename_table(
236-
cr,
237-
table_of_model(cr, old),
238-
table_of_model(cr, new),
239-
)
235+
old_table = table_of_model(cr, old)
236+
new_table = table_of_model(cr, new)
237+
if new_table != old_table:
238+
pg_rename_table(cr, old_table, new_table)
240239

241240
updates = [("wkf", "osv")] if table_exists(cr, "wkf") else []
242241
updates += [(ir.table, ir.res_model) for ir in indirect_references(cr) if ir.res_model]

0 commit comments

Comments
 (0)