[FIX] pos_self_order: prevent multi-company access error
Before this commit, if the POS user didn't have access to the first company, an access error would be raised when accessing the self-order page. The steps to reproduce this issue are as follows: 1. Add another company and set up POS self-order. 2. Remove the other company from the Marc user. 3. Open the POS in the new company. 4. Try to access the mobile menu. This would result in an access error. The issue was that the first company existed in the `allowed_company_ids` in the context. To solve this, we need to correctly set the `allowed_company_ids` in the context. opw-3744500 closes odoo/odoo#156357 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
@@ -323,7 +323,7 @@ class PosSelfOrderController(http.Controller):
|
||||
raise Unauthorized("Invalid access token")
|
||||
company = pos_config_sudo.company_id
|
||||
user = pos_config_sudo.current_session_id.user_id or pos_config_sudo.self_ordering_default_user_id
|
||||
return pos_config_sudo.sudo(False).with_company(company).with_user(user)
|
||||
return pos_config_sudo.sudo(False).with_company(company).with_user(user).with_context(allowed_company_ids=company.ids)
|
||||
|
||||
def _verify_authorization(self, access_token, table_identifier, take_away):
|
||||
"""
|
||||
@@ -338,5 +338,5 @@ class PosSelfOrderController(http.Controller):
|
||||
|
||||
company = pos_config.company_id
|
||||
user = pos_config.current_session_id.user_id or pos_config.self_ordering_default_user_id
|
||||
table = table_sudo.sudo(False).with_company(company).with_user(user)
|
||||
table = table_sudo.sudo(False).with_company(company).with_user(user).with_context(allowed_company_ids=company.ids)
|
||||
return pos_config, table
|
||||
|
||||
@@ -27,7 +27,7 @@ class PosSelfKiosk(http.Controller):
|
||||
|
||||
company = pos_config_sudo.company_id
|
||||
user = pos_config_sudo.current_session_id.user_id or pos_config_sudo.self_ordering_default_user_id
|
||||
pos_config = pos_config_sudo.sudo(False).with_company(company).with_user(user)
|
||||
pos_config = pos_config_sudo.sudo(False).with_company(company).with_user(user).with_context(allowed_company_ids=company.ids)
|
||||
|
||||
if not pos_config:
|
||||
raise werkzeug.exceptions.NotFound()
|
||||
|
||||
Reference in New Issue
Block a user