[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) <sgv@odoo.com>
This commit is contained in:
Ethan Vincent
2024-04-12 08:16:08 +00:00
parent 18157e2da2
commit db59937ee9
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -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/<int:company_id>', 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()
+1 -1
View File
@@ -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}',
}