Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Redirect to a specific URL after successful login

Naroči se

Get notified when there's activity on this post

This question has been flagged
actionLoginredirection
1 Odgovori
4319 Prikazi
Avatar
Prajwal

How to redirect to custom url after portal user successful login. Currently the portal user redirect to /my url of odoo. I have created custom module to redirect user to specific url after login, but the odoo does not invoke the custom controller it still used the odoo default login functionality. Following is my code please give me solution to achieve the functionality.

import logging

from odoo import http

from odoo.http import request

from odoo.exceptions import AccessDenied


_logger = logging.getLogger(__name__)


class CustomLoginRedirectController(http.Controller):


    # Override the default login route

    @http.route('/web/login', type='http', auth='none', website=True, csrf=False)

    def custom_web_login(self, redirect=None, **kw):

        """

        Override the default login behavior to redirect users to a custom URL after login.

        """

        _logger.info("Custom login controller invoked")


        # Ensure we have a valid database selected

        http.ensure_db()


        # If the user is already logged in, redirect to a custom URL

        if request.session.uid:

            _logger.info("User already logged in, redirecting to /buyer_search")

            # Custom redirect URL after login

            return request.redirect('/buyer_search')  # Replace with your custom URL


        # Values for the login page template

        values = request.params.copy()

        values['login_success'] = False


        try:

            values['databases'] = http.db_list()

        except AccessDenied:

            values['databases'] = None


        if request.httprequest.method == 'POST':

            login = request.params.get('login')

            password = request.params.get('password')


            _logger.info("POST request received. Attempting to authenticate user %s", login)


            try:

                # Authenticate the user using the credentials provided in the POST request

                if request.session.authenticate(request.db, login, password):

                    values['login_success'] = True

                    _logger.info("User %s authenticated successfully. Redirecting to /buyer_search", login)

                    # Redirect to the custom URL after successful login

                    return request.redirect('/buyer_search')  # Replace with your custom URL

                else:

                    # Invalid login credentials

                    values['error'] = 'Invalid username or password'

                    _logger.warning("Invalid login attempt for user %s", login)

            except AccessDenied as e:

                values['error'] = str(e)

                _logger.error("Access denied during login attempt for user %s: %s", login, str(e))


        # Handle GET requests and display the original login page

        _logger.info("Rendering the login page")

        response = request.render('web.login', values)

        response.headers['X-Frame-Options'] = 'DENY'

        return response




0
Avatar
Opusti
Avatar
Sylvain Michel Ratsarafahatra
Best Answer

Hello,

By default, for a portal user, the redirection is to /my, so if you want to redirect a user according to your conditions, you can redirect the user to another URL like the code below, adjusting it according to your needs.

from odoo.addons.web.controllers.home import Home as WebHome
from odoo.addons.web.controllers.utils import is_user_internal

class Home(WebHome):

def _login_redirect(self, uid, redirect=None):
if not redirect and not is_user_internal(uid):
redirect = '/buyer_search' # Replace with your custom URL
return super()._login_redirect(uid, redirect=redirect)

Best regards!

1
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Admin Email Password Reset & Full System Backup (Including GitHub)
action
Avatar
1
dec. 25
76
{Nú◈me↩ro telefone!Co↪pa}Qual o telefone da Copa Airlines?
action
Avatar
0
dec. 25
79
Enhanced Pricelist Discount Reporting and Accounting in Odoo 17
action
Avatar
0
dec. 25
7
How to Book Flights on Ex-pedia? ✈️ (Complete 2025 Guide)
action
Avatar
0
dec. 25
2
No error or warning message during import/export in Odoo Body:
action
Avatar
0
dec. 25
88
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now