From a7437aac104badd35e2dd48dd4fe2e96500ff8d2 Mon Sep 17 00:00:00 2001 From: dht-odoo Date: Thu, 27 May 2021 07:44:19 +0000 Subject: [PATCH] [IMP] website_form: converts text data into html data In website forms, for both html/text type of fields, we provide simple textarea to users for entering the data. And, we store the data as it is for both of them. But with this change, we're trying to convert plain text (entered by user in the online form for html type of fields) into to html, so for example it can replace \n with
and properly formatted data can be saved. Task id: 2499504 X-original-commit: b8d5b61333b0e8570ea2eb0535e37a0025514812 --- addons/website_form/controllers/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index 2e2b98c1fa1..b53dcab40af 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -3,16 +3,13 @@ import base64 import json -import pytz -from datetime import datetime from psycopg2 import IntegrityError from werkzeug.exceptions import BadRequest from odoo import http, SUPERUSER_ID, _ from odoo.http import request -from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT -from odoo.tools.translate import _ +from odoo.tools import plaintext2html from odoo.exceptions import ValidationError, UserError from odoo.addons.base.models.ir_qweb_fields import nl2br @@ -100,6 +97,9 @@ class WebsiteForm(http.Controller): def floating(self, field_label, field_input): return float(field_input) + def html(self, field_label, field_input): + return plaintext2html(field_input) + def boolean(self, field_label, field_input): return bool(field_input) @@ -115,7 +115,7 @@ class WebsiteForm(http.Controller): _input_filters = { 'char': identity, 'text': identity, - 'html': identity, + 'html': html, 'date': identity, 'datetime': identity, 'many2one': integer,