From b2c4c4301570dea3ab64b4ccd2c4c8b0e7d05e4d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 22 Jun 2020 12:25:51 +0000 Subject: [PATCH] [FIX] point_of_sale: resume session - Create a new POS session with User A - Make an order - Logout and connect as User B - Resume the session The session cannot be resumed and the user is redirected to the POS Dashboard. When searching for a session to resume, the search restricts the user to the current user. Therefore, no session is found. If no session is found, we search on sessions corresponding to the given configuration. The configuration is mandatory to avoid being redirected to a random session. opw-2274973 X-original-commit: 2deb94aa9da821455374df5602e2d30c5befcdec --- addons/point_of_sale/controllers/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py index f40a7cd5201..94a1da906bc 100644 --- a/addons/point_of_sale/controllers/main.py +++ b/addons/point_of_sale/controllers/main.py @@ -33,6 +33,18 @@ class PosController(http.Controller): if config_id: domain = AND([domain,[('config_id', '=', int(config_id))]]) pos_session = request.env['pos.session'].sudo().search(domain, limit=1) + + # The same POS session can be opened by a different user => search without restricting to + # current user. Note: the config must be explicitly given to avoid fallbacking on a random + # session. + if not pos_session and config_id: + domain = [ + ('state', '=', 'opened'), + ('rescue', '=', False), + ('config_id', '=', int(config_id)), + ] + pos_session = request.env['pos.session'].sudo().search(domain, limit=1) + if not pos_session: return werkzeug.utils.redirect('/web#action=point_of_sale.action_client_pos_menu') # The POS only work in one company, so we enforce the one of the session in the context