From 024010bbe17242537c691fb7f12db8655db8fe87 Mon Sep 17 00:00:00 2001 From: jvm-odoo Date: Fri, 21 Feb 2020 13:32:18 +0000 Subject: [PATCH] [FIX] website_form: fix wrong user sending website forms Issue - Set outgoing mail server - Install Online Ticket Submission - Publish an Helpdesk Team - Log out - Create a ticket from the helpdesk form The user who created the ticket is "Public User" He has no email address, so the mail is not sent Cause insert_record method in website_form/main.py uses .sudo() In v12 => sudo replaces the user in env by the superuser => ok In v13 => sudo adds a flag "su" and does not replace the user in env Solution Add a with_user(SUPERUSER_ID) to the create method's call in insert_record OPW-2196668 closes odoo/odoo#46835 X-original-commit: 761ae16634b14bec7be522666bb2163490566ecc Signed-off-by: Jason Van Malder (jvm) --- addons/website_form/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index 1e3614bf3d5..c6708b2fac6 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -182,7 +182,7 @@ class WebsiteForm(http.Controller): model_name = model.sudo().model if model_name == 'mail.mail': values.update({'reply_to': values.get('email_from')}) - record = request.env[model_name].sudo().with_context(mail_create_nosubscribe=True).create(values) + record = request.env[model_name].with_user(SUPERUSER_ID).with_context(mail_create_nosubscribe=True).create(values) if custom or meta: _custom_label = "%s\n___________\n\n" % _("Other Information:") # Title for custom fields