Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
3944 Näkymät

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
Hylkää
Tekijä Paras vastaus

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
Hylkää

this works, thanks

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
jouluk. 24
1327
3
toukok. 24
1939
1
jouluk. 23
2274
2
huhtik. 23
2057
2
jouluk. 22
8771