summaryrefslogtreecommitdiff
path: root/addons/website_livechat/models
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2019-01-03 08:19:21 +0000
committerjem-odoo <jem@openerp.com>2019-04-01 07:03:11 +0000
commitc04b9c019eb4c04d62d1d90b810c5407d8a9b5bd (patch)
tree8d6d9d1e1b36c750c5b552b81ca33fa39094e147 /addons/website_livechat/models
parent92e9e84b63a266b39d556c1db1d336373dc8b303 (diff)
[REF] im_livechat: rework some 'im_livechat.channel' model methods
Purpose ======= Several methods of the 'im_livechat.channel' model were passed a 'channel_id' to work on. This has been changed so that the caller can use those methods on an instance of this model instead. Some methods have also been switched to private because they had no apparent reasons to be public. This is a preliminary cleaning for task #1919871 Specicial note for the "loader" template: To load the livechat assets in a website page, the 'loader' template of livechat is directly called (instead of being returned through a controller) in order to avoid a new call to server. As this commit moves 'sudo' to make method callable on the record directly, it still needs to be sudo. First solution was to add the 'sudo' in the template, which is a bad practise. This commit creates a proxy method on website model returning the livechat info with 'sudo'. This avoid having the 'sudo' done in template. Like always, explicit is better than implicit. Task-1919871
Diffstat (limited to 'addons/website_livechat/models')
-rw-r--r--addons/website_livechat/models/website.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/website_livechat/models/website.py b/addons/website_livechat/models/website.py
index e207482416a..c52dc9a09f0 100644
--- a/addons/website_livechat/models/website.py
+++ b/addons/website_livechat/models/website.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import fields, models
+from odoo import api, fields, models
class Website(models.Model):
@@ -9,3 +9,13 @@ class Website(models.Model):
_inherit = "website"
channel_id = fields.Many2one('im_livechat.channel', string='Website Live Chat Channel')
+
+ @api.multi
+ def get_livechat_channel_info(self):
+ """ Get the livechat info dict (button text, channel name, ...) for the livechat channel of
+ the current website.
+ """
+ self.ensure_one()
+ if self.channel_id:
+ return self.channel_id.sudo().get_livechat_info()
+ return {}