简体   繁体   English

Odoo,防止网页登录后重定向

[英]Odoo, prevent redirecting after web login

After I login to odoo from localhost:8069/web/login I get redirected to Odoo backend, from where I need to click Website to come back to Home Page .localhost:8069/web/login到 odoo 后,我被重定向到 Odoo 后端,从那里我需要单击Website返回主页

How can I prevent this?我怎样才能防止这种情况? I need to stay inside the home page after login.登录后我需要留在主页内。

EDIT: @moskiSRB 's answer solves the problem for simple login.编辑: @moskiSRB 的回答解决了简单登录的问题。 But after Signup there is auto login which still leads to backend但是注册后有自动登录仍然导致后端

If you wanna set this for all website users you need to set them to portal users.如果您想为所有网站用户设置此项,您需要将他们设置为门户用户。 Also, you can set under Users->Preferences->Home Action set to Website .此外,您可以在Users->Preferences->Home Action设置为Website

UPDATE更新

For signup new users you need to create template user account and check portal options for that user.对于注册新用户,您需要创建模板用户帐户并检查该用户的门户选项。 Next, go to Settings->General Settings under Portal Access find Template user for new users created through signup choose your template user.接下来,转到Settings->General Settings Portal Access Settings->General Settings下的Settings->General SettingsTemplate user for new users created through signup找到Template user for new users created through signup选择您的模板用户。

you can create a model that inherits from res.user and modify the action_id with a compute.您可以创建一个从 res.user 继承的模型并使用计算修改 action_id。

class InheritResUsers(models.Model):
    _name = 'res.users'
    _inherit = ['res.users']

# Nouveaux champs
action_id = fields.Many2one('ir.actions.actions', string='Home Action', compute='get_home_page')

def get_home_page(self):

    for project in self:
        # we position ourselves in the ir.actions.act_window model
        tasks = self.env['ir.actions.act_window']
        #we search for the specific view by using the name and une xml_id
        task_ids = tasks.search(
            [['xml_id', '=', '  project.open_view_project_all'], ['name', '=', 'Projects']])
        for task in task_ids:  # Browse the table by adding the page id to the inherited action_id field
            self.action_id=task.id
InheritResUsers()

Here I redirect to the home page of my module.在这里,我重定向到我的模块的主页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM