summaryrefslogtreecommitdiff
path: root/addons/website_form
diff options
context:
space:
mode:
authorjvm-odoo <jvm@odoo.com>2020-03-27 07:34:28 +0000
committerjvm-odoo <jvm@odoo.com>2020-03-27 09:50:27 +0000
commit70a79da8a06a3096ea82da6c0d7b26b73811a1c6 (patch)
treeff486777babb4e1037ba3ae7897adb64b7a33a08 /addons/website_form
parent20fd2e38c943c5397a49e654c1fb53da45e8ef1a (diff)
[FIX] website_form: fix wrong user sending email
Issue When you send a form which create a customer from the website, you get a 400 error. I used the customer database to reproduce the issue. I guess this is due to specific settings who set a value for `meta` here https://github.com/odoo/odoo/blob/5381e9d900b344e7d48a6b347c5fc551d433b15e/addons/website_form/controllers/main.py#L187 Cause The cause is the same than the one for fc8a0474b4 Here, we use sudo: https://github.com/odoo/odoo/blob/5381e9d900b344e7d48a6b347c5fc551d433b15e/addons/website_form/controllers/main.py#L211 sudo adds a flag "su" and does not replace the user in env So we have "public user" who doesn't have email instead of OdooBot who has an email, there is a raise who explain the issue but it's not forwarded to the error in the website Solution Use with_user(SUPERUSER_ID) instead of sudo, in order to have the right user (as it is done few lines above. OPW-2220816 closes odoo/odoo#48481 X-original-commit: 1dba2ec8166b934d0698220e7062280d347f8af1 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
Diffstat (limited to 'addons/website_form')
-rw-r--r--addons/website_form/controllers/main.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py
index c6708b2fac6..218c8189306 100644
--- a/addons/website_form/controllers/main.py
+++ b/addons/website_form/controllers/main.py
@@ -208,7 +208,7 @@ class WebsiteForm(http.Controller):
'no_auto_thread': False,
'res_id': record.id,
}
- mail_id = request.env['mail.message'].sudo().create(values)
+ mail_id = request.env['mail.message'].with_user(SUPERUSER_ID).create(values)
return record.id