summaryrefslogtreecommitdiff
path: root/addons/mail_bot/models
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-06-25 10:12:17 +0000
committerSébastien Theys <seb@odoo.com>2020-06-25 12:54:26 +0000
commit6da8fac5f46a0040fe8185e83a3f6a4a3c653464 (patch)
treeead63ef392215221f4eb6a1431a6e3660bc390b6 /addons/mail_bot/models
parent7ab957d7b07e53d23872351919bf91de3a340d97 (diff)
[FIX] mail_bot: fix OdooBot not starting
- fix initializer start override (typo in method name) - properly wrap async code in models - disable OdooBot for System user - use existing python method to create chat task-2284584 closes odoo/odoo#53669 X-original-commit: 47bbfeab9e238ab542d16bf4ed17d60ad6aea50d Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail_bot/models')
-rw-r--r--addons/mail_bot/models/mail_channel.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/addons/mail_bot/models/mail_channel.py b/addons/mail_bot/models/mail_channel.py
index 6abccc8b426..a5e9a60a528 100644
--- a/addons/mail_bot/models/mail_channel.py
+++ b/addons/mail_bot/models/mail_channel.py
@@ -14,15 +14,9 @@ class Channel(models.Model):
@api.model
def init_odoobot(self):
if self.env.user.odoobot_state in [False, 'not_initialized']:
- partner = self.env.user.partner_id
odoobot_id = self.env['ir.model.data'].xmlid_to_res_id("base.partner_root")
- channel = self.with_context(mail_create_nosubscribe=True).create({
- 'channel_partner_ids': [(4, partner.id), (4, odoobot_id)],
- 'public': 'private',
- 'channel_type': 'chat',
- 'email_send': False,
- 'name': 'OdooBot'
- })
+ channel_info = self.channel_get([odoobot_id])
+ channel = self.browse(channel_info['id'])
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> <span class=\"o_odoobot_command\">:)</span>")
channel.sudo().message_post(body=message, author_id=odoobot_id, message_type="comment", subtype_xmlid="mail.mt_comment")
self.env.user.odoobot_state = 'onboarding_emoji'