[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) <jvm@odoo.com>
This commit is contained in:
jvm-odoo
2020-03-04 09:53:50 +00:00
parent 617e53229e
commit 024010bbe1
+1 -1
View File
@@ -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