diff options
| author | Martin Trigaux <mat@odoo.com> | 2018-08-27 10:28:48 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2018-09-03 11:06:59 +0200 |
| commit | d6a0e9db819ea279fabdaa427dca81247fa9608c (patch) | |
| tree | 038176cad94d6fb2afa2c5c5ad13a52f37a4ce55 /addons/mail_bot/models | |
| parent | 933487eb656addf131396d80ef23422dff5ec323 (diff) | |
[FIX] mail_bot: do not crash on user with no email
When creating a new user, the linked partner may not yet have an email address
(not mandatory field).
When logging in for the first time, after some time an error comes up
"Unable to post message, please configure the sender's email address."
While the user should set up an email, this popup coming from no specific action
is confusing.
With this patch, the message will be posted as the system (which has an email)
The user will be warned of having no email when trying to reply.
Closes #26601
Diffstat (limited to 'addons/mail_bot/models')
| -rw-r--r-- | addons/mail_bot/models/mail_bot.py | 2 | ||||
| -rw-r--r-- | addons/mail_bot/models/mail_channel.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/addons/mail_bot/models/mail_bot.py b/addons/mail_bot/models/mail_bot.py index 0d311922cc1..6c340193809 100644 --- a/addons/mail_bot/models/mail_bot.py +++ b/addons/mail_bot/models/mail_bot.py @@ -29,7 +29,7 @@ class MailBot(models.AbstractModel): if answer: message_type = values.get('message_type', 'comment') subtype_id = values.get('subtype_id', self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment')) - record.with_context({"mail_create_nosubscribe": True}).message_post(body=answer, author_id=odoobot_id, message_type=message_type, subtype_id=subtype_id) + record.with_context({"mail_create_nosubscribe": True}).sudo().message_post(body=answer, author_id=odoobot_id, message_type=message_type, subtype_id=subtype_id) def _get_answer(self, record, body, values, command=False): # onboarding diff --git a/addons/mail_bot/models/mail_channel.py b/addons/mail_bot/models/mail_channel.py index 80e55fbacae..ded27db6f5e 100644 --- a/addons/mail_bot/models/mail_channel.py +++ b/addons/mail_bot/models/mail_channel.py @@ -36,6 +36,6 @@ class Channel(models.Model): 'name': 'OdooBot' }) message = _("Hello,<br/>Odoo's chat helps employees collaborate efficiently. I'm here to help you discover its features.<br/><b>Try to send me an emoji :)</b>") - channel.message_post(body=message, author_id=odoobot_id, message_type="comment", subtype="mail.mt_comment") + channel.sudo().message_post(body=message, author_id=odoobot_id, message_type="comment", subtype="mail.mt_comment") self.env.user.odoobot_state = 'onboarding_emoji' return channel |
