Files
odoo_source/addons/mail_bot/models/mail_channel.py
T
Sébastien Theys 6da8fac5f4 [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>
2020-06-25 12:54:26 +00:00

24 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, _
class Channel(models.Model):
_inherit = 'mail.channel'
def _execute_command_help(self, **kwargs):
super(Channel, self)._execute_command_help(**kwargs)
self.env['mail.bot']._apply_logic(self, kwargs, command="help") # kwargs are not usefull but...
@api.model
def init_odoobot(self):
if self.env.user.odoobot_state in [False, 'not_initialized']:
odoobot_id = self.env['ir.model.data'].xmlid_to_res_id("base.partner_root")
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'
return channel