From bfee82860305660ad3513d6036806bda421be33e Mon Sep 17 00:00:00 2001 From: std-odoo Date: Mon, 30 May 2022 10:40:08 +0000 Subject: [PATCH] [FIX] website: add the email of when a user fill the website form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose ======= When a public user fill a form on Website (e.g. /contactus), an email will be sent. The email filled in the form will be used as the "email from", but if no mail server match this email address it will be encapsulated into "`notifications@mycompany.com`" (see odoo/odoo#61853). Even though the email is still present in the "Reply-To" header, we want to add it at the end of the email, so the receiver has this information easily. Task-2833093 closes odoo/odoo#94728 X-original-commit: a57944cc387a0b2f0eb6450a14a14e149c720181 Signed-off-by: Warnon Aurélien (awa) --- addons/website/controllers/form.py | 9 +++++++++ addons/website/i18n/website.pot | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/addons/website/controllers/form.py b/addons/website/controllers/form.py index a9674c0b4e6..b45c97207f0 100644 --- a/addons/website/controllers/form.py +++ b/addons/website/controllers/form.py @@ -173,6 +173,15 @@ class WebsiteForm(http.Controller): except ValueError: error_fields.append(field_name) + if dest_model._name == 'mail.mail' and field_name == 'email_from': + # As the "email_from" is used to populate the email_from of the + # sent mail.mail, it could be filtered out at sending time if no + # outgoing mail server "from_filter" match the sender email. + # To make sure the email contains that (important) information + # we also add it to the "custom message" that will be included + # in the body of the email sent. + custom_fields.append((_('email'), field_value)) + # If it's a custom field elif field_name != 'context': custom_fields.append((field_name, field_value)) diff --git a/addons/website/i18n/website.pot b/addons/website/i18n/website.pot index ccbf47dc44e..7cd49f18b85 100644 --- a/addons/website/i18n/website.pot +++ b/addons/website/i18n/website.pot @@ -10597,6 +10597,12 @@ msgstr "" msgid "eLearning" msgstr "" +#. module: website +#: code:addons/website/controllers/form.py:0 +#, python-format +msgid "email" +msgstr "" + #. module: website #. openerp-web #: code:addons/website/static/src/xml/website.xml:0