summaryrefslogtreecommitdiff
path: root/addons/mail_bot/models/mail_channel.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/mail_bot/models/mail_channel.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/mail_bot/models/mail_channel.py')
-rw-r--r--addons/mail_bot/models/mail_channel.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/addons/mail_bot/models/mail_channel.py b/addons/mail_bot/models/mail_channel.py
new file mode 100644
index 00000000..a5e9a60a
--- /dev/null
+++ b/addons/mail_bot/models/mail_channel.py
@@ -0,0 +1,23 @@
+# -*- 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