Skip to content

Commit

Permalink
[IMP] rename_fields: make a complete renaming of a field with side
Browse files Browse the repository at this point in the history
features: filters
  • Loading branch information
royle-vietnam committed Jul 11, 2022
1 parent 96a0ddc commit 4023e0e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,31 @@ def rename_fields(env, field_spec, no_deep=False):
AND context ~ %(old_pattern)s
""" % {
'old_pattern': (
r"$$('group_by'|'col_group_by'):([^\]]*)"
r"""$$('group_by'|'col_group_by'|'graph_groupbys'
|'pivot_measures'|'pivot_row_groupby'|'pivot_column_groupby'
):([\s*][^\]]*)"""
r"'%s(:day|:week|:month|:year){0,1}'(.*?\])$$"
) % old_field,
'new_pattern': r"$$\1:\2'%s\3'\4$$" % new_field,
}, (model, ),
)
# Examples of replaced contexts:
# {'graph_measure': 'field'
cr.execute(r"""
UPDATE ir_filters
SET context = regexp_replace(
context, %(old_pattern)s, %(new_pattern)s
)
WHERE model_id = %%s
AND context ~ %(old_pattern)s
""" % {
'old_pattern': (
r"$$'graph_measure':([\s*])'%s(:day|:week|:month|:year){0,1}'$$"
) % old_field,
'new_pattern': r"$$'graph_measure':\1'%s\2'$$" % new_field,
}, (model, ),
)
# TODO: Rename when the field in ir_ui_view_custom
if table_exists(env.cr, 'mail_alias'):
# Rename appearances on mail alias
cr.execute("""
Expand Down

0 comments on commit 4023e0e

Please sign in to comment.