Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4193 Lượt xem

I have a piece of codes to send an email to a user when he did made some choice on the website. The code use the following function to create the email

 http.request.env['mail.mail'].create(mail_values).send()

But it only works when I used admin to login, otherwise, I was given the error:

odoo.exceptions.AccessError: You are not allowed to create 'Outgoing Mails' (mail.mail) records.

This operation is allowed for the following groups:

        - Administration/Settings

I try to find option in settings to grant the permission of sending email to all user. But I cannot find such option. Please help me solve this issue. Thank you very much in advance.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I find the answer now. I must use sudo to create, i.e. http.request.env['mail.mail'].sudo().create(mail_values).send(), then I can send mails in the method of handling the session of any user.

Ảnh đại diện
Huỷ bỏ

this works, thanks

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1547
3
thg 5 24
2144
1
thg 12 23
2480
2
thg 4 23
2204
2
thg 12 22
9034