How to redirect to a model's form view from a controller without going through the auth view

18 Views Asked by At

I am doing work in Odoo 16 as part of a project at my work and I need, from a URL, for the user to access the view of the model without going through the authentication view, I have done this:

from odoo import http
from odoo.http import request

class RestAPI(http.Controller):
  
  @http.route('/client_document/<id>/<token>', auth='public', type='http', methods=['GET','POST'])
  def api_show_client_document(self, id, token, **kwargs):

      user_id = request.env['res.users.apikeys']._check_credentials(scope='odoo.web', key=token)
      if not user_id: return 'invalid token'
      request.update_env(user=user_id)
      url = '/web#id=%s&view_type=form&model=client.document' % id
      return request.redirect(url)

The problem is that it is always directing me to the authentication page and it is not what is desired. How can I make Odoo recognize that the user is already authenticated by me given the token and let him directly access the model whose id is Please specify, someone who can help me, thank you

0

There are 0 best solutions below