Skip to content

Commit

Permalink
Merge pull request #310 from legalsylvain/16.0-fix-ir-translation
Browse files Browse the repository at this point in the history
[FIX] adapt common openupgradelib functions to V16. (ir_translation table has been removed)
  • Loading branch information
pedrobaeza authored Oct 31, 2022
2 parents 94762d1 + 8de9469 commit f0b809f
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,17 @@ def rename_fields(env, field_spec, no_deep=False):
""", (new_field, old_field, model),
)
# Rename translations
cr.execute("""
UPDATE ir_translation
SET name = %s
WHERE name = %s
AND type = 'model'
""", (
"%s,%s" % (model, new_field),
"%s,%s" % (model, old_field),
),
)
if version_info[0] < 16:
cr.execute("""
UPDATE ir_translation
SET name = %s
WHERE name = %s
AND type = 'model'
""", (
"%s,%s" % (model, new_field),
"%s,%s" % (model, old_field),
),
)
# Rename possible attachments (if field is Binary with attachment=True)
if column_exists(cr, "ir_attachment", "res_field"):
cr.execute("""
Expand Down Expand Up @@ -843,13 +844,14 @@ def rename_models(cr, model_spec):
'UPDATE ir_model_fields SET model = %s '
'WHERE model = %s', (new, old,),
)
logged_query(
cr,
"UPDATE ir_translation SET "
"name=%s || substr(name, strpos(name, ',')) "
"WHERE name LIKE %s",
(new, old + ',%'),
)
if version_info[0] < 16:
logged_query(
cr,
"UPDATE ir_translation SET "
"name=%s || substr(name, strpos(name, ',')) "
"WHERE name LIKE %s",
(new, old + ',%'),
)
logged_query(
cr,
"UPDATE ir_filters SET model_id = %s "
Expand Down Expand Up @@ -1573,7 +1575,7 @@ def update_module_names(cr, namespec, merge_modules=False):
query = ("UPDATE ir_module_module_dependency SET name = %s "
"WHERE name = %s")
logged_query(cr, query, (new_name, old_name))
if version_info[0] > 7:
if version_info[0] > 7 and version_info[0] < 16:
query = ("UPDATE ir_translation SET module = %s "
"WHERE module = %s")
logged_query(cr, query, (new_name, old_name))
Expand Down Expand Up @@ -2691,6 +2693,8 @@ def update_module_moved_fields(
)
# update ir_translation - it covers both <=v8 through type='field' and
# >=v9 through type='model' + name
if version_info[0] > 15:
return
logged_query(
cr, """
UPDATE ir_translation it
Expand Down Expand Up @@ -2764,6 +2768,8 @@ def update_module_moved_models(cr, model, old_module, new_module):
AND imf.model = %s AND imd.module = %s""",
(new_module, AsIs(table), AsIs(underscore), model, old_module),
)
if version_info[0] > 15:
return
logged_query(
cr,
"UPDATE ir_translation SET module=%s "
Expand Down

0 comments on commit f0b809f

Please sign in to comment.