[FIX] mail: Fix /mail/view/ controller when not logged in
closes odoo/odoo#33756 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -53,6 +53,7 @@ class MailController(http.Controller):
|
||||
# to give access to the record to a recipient that has normally no access.
|
||||
uid = request.session.uid
|
||||
user = request.env['res.users'].sudo().browse(uid)
|
||||
cids = False
|
||||
|
||||
# no model / res_id, meaning no possible record -> redirect to login
|
||||
if not model or not res_id or model not in request.env:
|
||||
@@ -125,7 +126,8 @@ class MailController(http.Controller):
|
||||
if view_id:
|
||||
url_params['view_id'] = view_id
|
||||
|
||||
url_params['cids'] = ','.join([str(cid) for cid in cids])
|
||||
if cids:
|
||||
url_params['cids'] = ','.join([str(cid) for cid in cids])
|
||||
url = '/web?#%s' % url_encode(url_params)
|
||||
return werkzeug.utils.redirect(url)
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ class TestMultiCompany(HttpCase):
|
||||
|
||||
def test_redirect_to_records(self):
|
||||
|
||||
self.authenticate('admin', 'admin')
|
||||
|
||||
self.company_A = self.env['res.company'].create({
|
||||
'name': 'Company A',
|
||||
'user_ids': [(4, self.ref('base.user_admin'))],
|
||||
@@ -25,6 +23,17 @@ class TestMultiCompany(HttpCase):
|
||||
'company_id': self.company_A.id,
|
||||
})
|
||||
|
||||
# Test Case 0
|
||||
# Not logged, redirect to web/login
|
||||
response = self.url_open('/mail/view?model=%s&res_id=%s' % (
|
||||
self.multi_company_record._name,
|
||||
self.multi_company_record.id), timeout=15)
|
||||
|
||||
path = url_parse(response.url).path
|
||||
self.assertEqual(path, '/web/login')
|
||||
|
||||
self.authenticate('admin', 'admin')
|
||||
|
||||
# Test Case 1
|
||||
# Logged into company 1, try accessing record in company A
|
||||
# _redirect_to_record should add company A in allowed_company_ids
|
||||
|
||||
Reference in New Issue
Block a user