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

[IMP] rename_models: add condition to check version and existence of ir_property table #395

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
35 changes: 18 additions & 17 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,19 +975,6 @@ def rename_models(cr, model_spec):
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,
"SELECT id FROM ir_model_fields "
Expand All @@ -1003,20 +990,34 @@ def rename_models(cr, model_spec):
old,
),
)
if field_ids:
if version_info[0] < 18:
logged_query(
cr,
"""
UPDATE ir_property
SET value_reference = replace(
value_reference, %(old_string)s, %(new_string)s)
WHERE value_reference like %(old_pattern)s""",
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
if field_ids:
logged_query(
cr,
"""
UPDATE ir_property
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,
},
)
# Handle models that reference to this model using reference fields
cr.execute(
"""
Expand Down
Loading