summaryrefslogtreecommitdiff
path: root/addons/hr_attendance
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2019-01-03 18:03:48 +0000
committerNicolas Martinelli <nim@odoo.com>2019-01-04 09:56:55 +0000
commit6da2e23e65ddcbdc0133c92151335db24d30362e (patch)
tree4ae72432aa76ac8d331ca31d780fb95ca25d65bc /addons/hr_attendance
parent79b80d9c37e689f966dd310c012518f33239b275 (diff)
[FIX] hr_attendance: kiosk keep alive
When running in kiosk mode, it is necessary to refresh the interface once a week since the session is garbage collected. The garbage collection method `session_gc` relies on the last modification time of the session file. However, the session file is only saved when the field key `should_save` of the session request is `True`. This happens when the session is `modified`, i.e. an item on the cookie is set. In practice, the session is saved at each reload of the page. Regular RPC calls, such as the one used in commit 6e1b660f9c76a41, do not trigger a modification of the session file. Therefore, we create a new route which explicitly sets the session as `modified`, which ultimately triggers a `save` in `get_response`. opw-1917254 closes odoo/odoo#29919
Diffstat (limited to 'addons/hr_attendance')
-rw-r--r--addons/hr_attendance/__init__.py1
-rw-r--r--addons/hr_attendance/controllers/__init__.py3
-rw-r--r--addons/hr_attendance/controllers/main.py12
-rw-r--r--addons/hr_attendance/static/src/js/kiosk_mode.js2
4 files changed, 17 insertions, 1 deletions
diff --git a/addons/hr_attendance/__init__.py b/addons/hr_attendance/__init__.py
index dc5e6b693d1..7d34c7c054a 100644
--- a/addons/hr_attendance/__init__.py
+++ b/addons/hr_attendance/__init__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from . import controllers
from . import models
diff --git a/addons/hr_attendance/controllers/__init__.py b/addons/hr_attendance/controllers/__init__.py
new file mode 100644
index 00000000000..65a8c12013d
--- /dev/null
+++ b/addons/hr_attendance/controllers/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import main
diff --git a/addons/hr_attendance/controllers/main.py b/addons/hr_attendance/controllers/main.py
new file mode 100644
index 00000000000..66534933c60
--- /dev/null
+++ b/addons/hr_attendance/controllers/main.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import http
+from odoo.http import request
+
+
+class HrAttendance(http.Controller):
+ @http.route('/hr_attendance/kiosk_keepalive', auth='user', type='json')
+ def kiosk_keepalive(self):
+ request.httprequest.session.modified = True
+ return {}
diff --git a/addons/hr_attendance/static/src/js/kiosk_mode.js b/addons/hr_attendance/static/src/js/kiosk_mode.js
index 07b03aa8b97..cbb84282eff 100644
--- a/addons/hr_attendance/static/src/js/kiosk_mode.js
+++ b/addons/hr_attendance/static/src/js/kiosk_mode.js
@@ -69,7 +69,7 @@ var KioskMode = AbstractAction.extend({
_callServer: function () {
// Make a call to the database to avoid the auto close of the session
- return ajax.rpc("/web/webclient/version_info", {});
+ return ajax.rpc("/hr_attendance/kiosk_keepalive", {});
},
});