Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] rename_models: also rename models in res_id of ir.property #275

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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