Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Redirect to a specific URL after successful login

Odoberať

Get notified when there's activity on this post

This question has been flagged
actionLoginredirection
1 Odpoveď
4280 Zobrazenia
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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
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
{~!@!IBeria52MX} ¿Cómo puedo reservar mi vuelo en Iberia?
action
Avatar
0
dec 25
5
odoo 19, Social Marketing module
action
Avatar
Avatar
1
dec 25
400
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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