Coverage for ingadhoc-odoo-saas-adhoc / saas_provider_upgrade / models / website.py: 45%
9 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:15 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:15 +0000
1from odoo import fields, models
4class Website(models.Model):
5 _inherit = "website"
7 upgrade_channel_id = fields.Many2one(
8 "im_livechat.channel",
9 string="Upgrade Website Live Chat Channel",
10 help="Upgrade live chat channel for the website. If this field is not set, the default channel will be used. "
11 "The default channel must be set to work properly.",
12 )
14 def _get_livechat_channel_info(self):
15 """
16 Get the livechat info dict (button text, channel name, ...) for the livechat channel of
17 the current website.
18 This method is overridden to support multiple livechat channels for different service levels.
19 The method checks the service level of the user's saas portal access and returns the corresponding
20 livechat channel info.
21 If the website has no channel_id, even if the specific service level channel information is returned,
22 the channel will not be displayed.
23 """
24 self.ensure_one()
25 if "/my/upgrade_ticket" in self.env.context.get("current_url", "") and self.upgrade_channel_id:
26 # If the user is on the upgrade ticket page, use the upgrade channel
27 # sudo - im_livechat.channel: getting bsaic info related to live chat channel is allowed.
28 return self.upgrade_channel_id.sudo().get_livechat_info()
29 else:
30 return super()._get_livechat_channel_info()