Files
odoo_source/addons/im_livechat/models/chatbot_message.py
T
Sébastien Theys 90cb44e1e1 [REF] mail, *: rename mail.channel to discuss.channel
* = bus, calendar, crm_livechat, hr, hr_holidays, im_livechat, mail_bot,
    mass_mailing, privacy_lookup, test_discuss_full, test_mail,
    test_mail_full, website_crm_livechat, website_livechat, base

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#118354

Related: odoo/upgrade#4553
Related: odoo/enterprise#39661
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-21 02:21:53 +02:00

29 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields
class ChatbotMailMessage(models.Model):
""" Chatbot Mail Message
We create a new model to store the related step to a mail.message and the user's answer.
We do this in a new model to avoid bloating the 'mail.message' model.
"""
_name = 'chatbot.message'
_description = 'Chatbot Message'
_order = 'create_date desc, id desc'
_rec_name = 'discuss_channel_id'
mail_message_id = fields.Many2one('mail.message', string='Related Mail Message', required=True, ondelete="cascade")
discuss_channel_id = fields.Many2one('discuss.channel', string='Discussion Channel', required=True, ondelete="cascade")
script_step_id = fields.Many2one(
'chatbot.script.step', string='Chatbot Step', required=True, ondelete='cascade')
user_script_answer_id = fields.Many2one('chatbot.script.answer', string="User's answer", ondelete="set null")
user_raw_answer = fields.Html(string="User's raw answer")
_sql_constraints = [
('_unique_mail_message_id', 'unique (mail_message_id)',
"A mail.message can only be linked to a single chatbot message"),
]