Skip to content

Commit e94ed12

Browse files
nseinletKangOl
authored andcommitted
[IMP] util.rename_model: skip useless queries
When renaming models, indirect references should be updated. In some cases, there's no record to update, but system spend time to execute the useless queries. closes #31 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 3c8c34c commit e94ed12

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/util/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ def rename_model(cr, old, new, rename_table=True):
220220
updates += [(ir.table, ir.res_model) for ir in indirect_references(cr) if ir.res_model]
221221

222222
for table, column in updates:
223+
cr.execute("SELECT 1 FROM {t} WHERE {c}=%s LIMIT 1".format(t=table, c=column), [old])
224+
if not cr.fetchone():
225+
continue
223226
query = cr.mogrify("UPDATE {t} SET {c}=%s WHERE {c}=%s".format(t=table, c=column), [new, old]).decode()
224227
explode_execute(cr, query, table=table)
225228

0 commit comments

Comments
 (0)