summaryrefslogtreecommitdiff
path: root/addons/hr_presence/controllers/bus_controller.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_presence/controllers/bus_controller.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/hr_presence/controllers/bus_controller.py')
-rw-r--r--addons/hr_presence/controllers/bus_controller.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/hr_presence/controllers/bus_controller.py b/addons/hr_presence/controllers/bus_controller.py
new file mode 100644
index 00000000..685ac4e5
--- /dev/null
+++ b/addons/hr_presence/controllers/bus_controller.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+from odoo import registry, SUPERUSER_ID
+from odoo.api import Environment
+from odoo.addons.bus.controllers.main import BusController
+from odoo.fields import Datetime
+from odoo.http import Controller, request, route
+
+
+class BusController(BusController):
+
+ @route('/longpolling/poll', type="json", auth="public")
+ def poll(self, channels, last, options=None):
+ if request.env.user.has_group('base.group_user'):
+ ip_address = request.httprequest.remote_addr
+ users_log = request.env['res.users.log'].search_count([
+ ('create_uid', '=', request.env.user.id),
+ ('ip', '=', ip_address),
+ ('create_date', '>=', Datetime.to_string(Datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)))])
+ if not users_log:
+ with registry(request.env.cr.dbname).cursor() as cr:
+ env = Environment(cr, request.env.user.id, {})
+ env['res.users.log'].create({'ip': ip_address})
+ return super(BusController, self).poll(channels, last, options=options)