Skip to content

Commit

Permalink
[FIX] website_form: fix wrong user sending website forms
Browse files Browse the repository at this point in the history
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#45944

Signed-off-by: Nicolas Martinelli (nim) <[email protected]>
  • Loading branch information
jvm-odoo committed Feb 24, 2020
1 parent 7bd18ff commit 761ae16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/website_form/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def insert_record(self, request, model, values, custom, meta=None):
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
Expand Down

0 comments on commit 761ae16

Please sign in to comment.