1

我在我们公司使用 odoo 作为系统,并希望使用该网站获取内部新闻和信息。然而,公众不应该看到该网站 - 只有登录的用户才能看到!未登录的观众应被重定向到登录屏幕。

这可能吗?我该怎么做?

4

2 回答 2

3

当您使用@http.route 定义路由时,您有一个参数“auth”,您可以在其中定义它。从odoo文档:

auth –

The type of authentication method, can on of the following:

    user: The user must be authenticated and the current request will perform using the rights of the user.
    public: The user may or may not be authenticated. If she isn’t, the current request will perform using the shared Public user.
    none: The method is always active, even if there is no database. Mainly used by the framework and authentication modules. There request code will not have any facilities to access the database nor have any configuration indicating the current database nor the current user.

看看https://www.odoo.com/documentation/12.0/reference/http.html

于 2019-03-22T17:27:14.067 回答
2

很简单,只需在控制器的 main.py 文件中的方法中给出auth="user"即可。

@http.route('/name', type='http', csrf=False, auth='user', website=True)
于 2019-03-28T06:35:09.610 回答