summaryrefslogtreecommitdiff
path: root/addons/im_support/models
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2018-05-18 13:17:42 +0200
committerAaron Bohy <aab@odoo.com>2018-05-28 07:30:12 +0200
commit2aeb7637689e3bd0e124b8effeb3f294e80eaad1 (patch)
tree1fce7bec5c0c5d8b511d1d0bb8437ff20ddd0732 /addons/im_support/models
parent10161f9d61fd4107ac48abdd6e243b3c9c7405cb (diff)
[ADD] im_support
This rev. adds a new module enabling the livechat support from the webclient. It allows employee users to communicate with livechat operators of another database, assuming that a counterpart addon is installed on that database. Task 26762 Co-authored-by: Adrien Dieudonne <adr@odoo.com>
Diffstat (limited to 'addons/im_support/models')
-rw-r--r--addons/im_support/models/__init__.py4
-rw-r--r--addons/im_support/models/ir_http.py27
2 files changed, 31 insertions, 0 deletions
diff --git a/addons/im_support/models/__init__.py b/addons/im_support/models/__init__.py
new file mode 100644
index 00000000000..75127bbcbc3
--- /dev/null
+++ b/addons/im_support/models/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import ir_http
diff --git a/addons/im_support/models/ir_http.py b/addons/im_support/models/ir_http.py
new file mode 100644
index 00000000000..39ff7081862
--- /dev/null
+++ b/addons/im_support/models/ir_http.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import hmac
+from hashlib import sha256
+
+from odoo import models
+from odoo.http import request
+
+
+class Http(models.AbstractModel):
+ _inherit = 'ir.http'
+
+ def session_info(self):
+ result = super(Http, self).session_info()
+
+ if self.env.user.has_group('base.group_user'):
+ icp = request.env['ir.config_parameter'].sudo()
+ db_uuid = icp.get_param('database.uuid')
+ db_secret = icp.get_param('database.secret')
+ message = db_uuid + str(request.uid)
+ token = hmac.new(message.encode('utf-8'), db_secret.encode('utf-8'), sha256).hexdigest()
+
+ result['db_uuid'] = db_uuid
+ result['support_token'] = token
+ result['support_origin'] = False # must be overridden to specify the correct origin
+
+ return result