[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.
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user