From 6f02ba9cbf8bf71dad468255579736b78b73b538 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 18 Nov 2015 11:41:25 +0100 Subject: [PATCH] [IMP] website_form: don't remove newline In some instance, the mail content of a sent form would only be text formatted. This could lead to a message with no newline, thus making it illegible. This fix has to be ugly since body_html field of a mail.mail is of type text. --- addons/website_form/controllers/main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index 8a296ef25c0..f7f5f0d07ef 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -155,16 +155,18 @@ class WebsiteForm(http.Controller): record = request.env[model.model].sudo().create(values) if custom or meta: - default_field_name = model.website_form_default_field_id.name - default_field_data = values.get(default_field_name, '') + default_field = model.website_form_default_field_id + default_field_data = values.get(default_field.name, '') custom_content = (default_field_data + "\n\n" if default_field_data else '') \ + (self._custom_label + custom + "\n\n" if custom else '') \ + (self._meta_label + meta if meta else '') # If there is a default field configured for this model, use it. # If there isn't, put the custom data in a message instead - if default_field_name: - record.update({default_field_name: custom_content}) + if default_field.name: + if default_field.ttype == 'html' or model.model == 'mail.mail': + custom_content = nl2br(custom_content) + record.update({default_field.name: custom_content}) else: values = { 'body': nl2br(custom_content),