You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo-v8技术咨询:如何实现未登录状态下单独访问首页?

Hey there! Let’s walk through exactly how to make your Odoo v8 homepage accessible without requiring users to log in—whether you want to unlock the existing system homepage or build a completely custom public landing page.

1. Make the Existing Odoo Homepage Accessible Without Login

If you want your current Odoo dashboard/homepage to be viewable by unauthenticated users, follow these steps:

  • Adjust the homepage route's authentication setting
    Odoo v8’s default homepage route (/web) is restricted to logged-in users. To change this, navigate to the web module’s controllers: web/controllers/main.py. Find the index method and modify the auth parameter in the @http.route decorator from "user" to "public" (allows access to the Public user group) or "none" (completely unrestricted access). For example:

    @http.route('/web', type='http', auth="public")
    def index(self, s_action=None, **kw):
        # Existing method code here
    
  • Grant necessary permissions to the Public group
    Go to Settings > Users > Groups, find the Public group, and add read access to models used by the homepage—typically ir.ui.menu (for menu items) and ir.ui.view (for page views). This ensures unauthenticated users can load the page’s components without permission errors.

  • Ensure homepage views are visible to Public users
    Edit the main homepage view (usually part of the web_client module) and set its access rights to allow the Public group to view it. You can do this via the view’s edit interface under Settings > Technical > User Interface > Views.

2. Create a Custom Public Homepage (No Login Required)

If you want a dedicated, brand-new page to serve as your public homepage, here’s how to build it:

  • Create a custom module
    Start by making a new module (e.g., custom_public_homepage) with the standard Odoo module structure:

    custom_public_homepage/
    ├── __init__.py
    ├── __openerp__.py
    ├── controllers/
    │   └── main.py
    └── views/
        └── templates.xml
    
  • Write the controller for your public route
    In controllers/main.py, define a route with auth='public' to handle unauthenticated requests. You can map it to the root path (/) so it loads when users visit your domain:

    from openerp import http
    from openerp.http import request
    
    class PublicHomepageController(http.Controller):
        @http.route('/', type='http', auth='public', website=True)
        def public_homepage(self, **kw):
            # Add any dynamic content logic here (e.g., fetch public products)
            return request.render('custom_public_homepage.public_home_template', {
                'greeting': 'Welcome to Our Public Portal!',
            })
    
  • Build the QWeb template
    In views/templates.xml, create a QWeb template for your homepage. You can inherit Odoo’s website.layout to keep consistent styling:

    <openerp>
        <data>
            <template id="public_home_template" name="Custom Public Homepage">
                <t t-call="website.layout">
                    <div class="container mt-5">
                        <h1 class="text-center"><t t-esc="greeting"/></h1>
                        <p class="text-center">This page is fully accessible without logging in.</p>
                        <!-- Add more content here (images, links, etc.) -->
                    </div>
                </t>
            </template>
        </data>
    </openerp>
    
  • Install and configure the module
    Install your new module via Odoo’s app store or by updating the module list. Once installed, the root path (/) will now load your custom public homepage. If you still need the original /web route for logged-in users, leave it unchanged—it’ll still work for authenticated users.

  • Secure your setup
    Avoid giving the Public group unnecessary permissions to sensitive models (like res.partner or account.move) to prevent unauthorized access to private data.

Quick Notes

  • Always test changes by logging out and accessing the page as an anonymous user to confirm it works.
  • Using auth="public" is safer than "none" because it ties access to the Public user group, letting you refine permissions later if needed.

内容的提问来源于stack exchange,提问作者Jesus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:27:20