Files
odoo_source/addons/website_livechat/models/im_livechat_channel.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

23 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
class ImLivechatChannel(models.Model):
_inherit = 'im_livechat.channel'
def _get_livechat_discuss_channel_vals(self, anonymous_name, operator=None, chatbot=None, user_id=None, country_id=None):
discuss_channel_vals = super(ImLivechatChannel, self)._get_livechat_discuss_channel_vals(anonymous_name, operator, chatbot, user_id=user_id, country_id=country_id)
visitor_sudo = self.env['website.visitor']._get_visitor_from_request()
if visitor_sudo:
discuss_channel_vals['livechat_visitor_id'] = visitor_sudo.id
# As chat requested by the visitor, delete the chat requested by an operator if any to avoid conflicts between two flows
# TODO DBE : Move this into the proper method (open or init mail channel)
chat_request_channel = self.env['discuss.channel'].sudo().search([('livechat_visitor_id', '=', visitor_sudo.id), ('livechat_active', '=', True)])
for discuss_channel in chat_request_channel:
operator_name = operator.name if operator else chatbot.operator_partner_id.name
discuss_channel._close_livechat_session(cancel=True, operator=operator_name)
return discuss_channel_vals