Skip to content

Commit

Permalink
[IMP] util/fields: update default when converting to html
Browse files Browse the repository at this point in the history
One could use Python escape sequences in text fields. When
converting a field to HTML, they will no longer work, so replace
them with HTML tags.
  • Loading branch information
diagnoza committed Oct 24, 2024
1 parent 4400cd3 commit e9d5416
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/util/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,23 @@ def convert_field_to_html(cr, model, field, skip_inherit=()):
""",
[field, model],
)

# Update ir.default
if table_exists(cr, "ir_default"):
cr.execute(
r"""
UPDATE ir_default AS d
SET json_value = REPLACE(
REPLACE(json_value, '\n', '<br/>'),
'\t', '&nbsp;&nbsp;&nbsp;&nbsp;'
)
FROM ir_model_fields AS imf
WHERE imf.name = %s
AND imf.model = %s
AND imf.id = d.field_id
""",
[field, model],
)
for inh in for_each_inherit(cr, model, skip_inherit):
convert_field_to_html(cr, inh.model, field, skip_inherit=skip_inherit)

Expand Down

0 comments on commit e9d5416

Please sign in to comment.