Skip to content

Commit

Permalink
Merge pull request #275 from ForgeFlow/master-rename_models-ir_proper…
Browse files Browse the repository at this point in the history
…ty-res_id

[FIX] rename_models: also rename models in res_id of ir.property
  • Loading branch information
pedrobaeza authored Feb 3, 2022
2 parents 2c57a5d + b540996 commit 0a74206
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,16 @@ def rename_models(cr, model_spec):
"UPDATE ir_filters SET model_id = %s "
"WHERE model_id = %s", (new, old,),
)
logged_query(
cr, """
UPDATE ir_property
SET res_id = replace(res_id, %(old_string)s, %(new_string)s)
WHERE res_id like %(old_pattern)s""", {
"old_pattern": "%s,%%" % old,
"old_string": "%s," % old,
"new_string": "%s," % new,
},
)
# Handle properties that reference to this model
logged_query(
cr,
Expand All @@ -841,14 +851,12 @@ def rename_models(cr, model_spec):
logged_query(
cr, """
UPDATE ir_property
SET value_reference = regexp_replace(
value_reference, %(old_pattern)s, %(new_pattern)s
)
WHERE fields_id IN %(field_ids)s
AND value_reference ~ %(old_pattern)s""", {
'field_ids': tuple(field_ids),
'old_pattern': r"^%s,[ ]*([0-9]*)" % old,
'new_pattern': r"%s,\1" % new,
SET value_reference = replace(
value_reference, %(old_string)s, %(new_string)s)
WHERE value_reference like %(old_pattern)s""", {
"old_pattern": "%s,%%" % old,
"old_string": "%s," % old,
"new_string": "%s," % new,
},
)
# Update export profiles references
Expand Down

0 comments on commit 0a74206

Please sign in to comment.