From db59937ee92b6cfc14b8563ce1504ccc79d659bc Mon Sep 17 00:00:00 2001 From: Ethan Vincent Date: Wed, 3 Apr 2024 09:33:02 +0200 Subject: [PATCH] [FIX] hr_attendance: route to kiosk with id slug **Current behavior:** Entering kiosk mode in the webclient in a multi-company env will display the logo of the default company. **Expected behavior:** The logo on the kiosk screen will belong to the currently selected company. **Steps to reproduce:** 1. Make a second company, give the default company and the new one distinct logos 2. Select the second company from the company selector menu 3. Enter kiosk mode in the Attendance app, observe the logo is that of the inactive company **Cause of the issue:** After arriving at the URL route for the kiosk page from the _action_open_kiosk_mode() method, the context has been rebuilt to a somewhat default state which no longer informs the current company id. `self.env.company` references the default company of the user. **Fix:** Add an id slug in the URL route which identifies which company's kiosk we should be seeing. opw-3802916 closes odoo/odoo#159702 Signed-off-by: Sofie Gvaladze (sgv) --- addons/hr_attendance/controllers/main.py | 8 +++++++- addons/hr_attendance/models/res_company.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/hr_attendance/controllers/main.py b/addons/hr_attendance/controllers/main.py index 711175e7317..2ac4c45cd46 100644 --- a/addons/hr_attendance/controllers/main.py +++ b/addons/hr_attendance/controllers/main.py @@ -52,15 +52,21 @@ class HrAttendance(http.Controller): @http.route('/hr_attendance/kiosk_mode_menu', auth='user', type='http') def kiosk_menu_item_action(self): + # better use route with company_id suffix if request.env.user.user_has_groups("hr_attendance.group_hr_attendance_manager"): # Auto log out will prevent users from forgetting to log out of their session # before leaving the kiosk mode open to the public. This is a prevention security # measure. request.session.logout(keep_db=True) - return request.redirect(request.env.user.company_id.attendance_kiosk_url) + return request.redirect(request.env.company.attendance_kiosk_url) else: return request.not_found() + @http.route('/hr_attendance/kiosk_mode_menu/', auth='user', type='http') + def kiosk_menu_item_action2(self, company_id): + request.update_context(allowed_company_ids=[company_id]) + return self.kiosk_menu_item_action() + @http.route('/hr_attendance/kiosk_keepalive', auth='user', type='json') def kiosk_keepalive(self): request.session.touch() diff --git a/addons/hr_attendance/models/res_company.py b/addons/hr_attendance/models/res_company.py index 74cdb652995..cb1f1b2b94f 100644 --- a/addons/hr_attendance/models/res_company.py +++ b/addons/hr_attendance/models/res_company.py @@ -120,5 +120,5 @@ class ResCompany(models.Model): return { 'type': 'ir.actions.act_url', 'target': 'self', - 'url': '/hr_attendance/kiosk_mode_menu' + 'url': f'/hr_attendance/kiosk_mode_menu/{self.env.company.id}', }