From 6da2e23e65ddcbdc0133c92151335db24d30362e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 3 Jan 2019 18:03:48 +0000 Subject: [PATCH] [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 --- addons/hr_attendance/__init__.py | 1 + addons/hr_attendance/controllers/__init__.py | 3 +++ addons/hr_attendance/controllers/main.py | 12 ++++++++++++ addons/hr_attendance/static/src/js/kiosk_mode.js | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 addons/hr_attendance/controllers/__init__.py create mode 100644 addons/hr_attendance/controllers/main.py 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", {}); }, });