Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
4106 Visualizações

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.

Avatar
Cancelar
Autor Melhor resposta

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.

Avatar
Cancelar

this works, thanks

Publicações relacionadas Respostas Visualizações Atividade
0
dez. 24
1514
3
mai. 24
2086
1
dez. 23
2420
2
abr. 23
2162
2
dez. 22
8964