从公共到用户更新Odoo网站路由时出现内部错误

时间:2019-09-30 15:51:37

标签: python odoo odoo-12

我试图限制所有经过身份验证的用户访问所有博客,因为默认情况下所有博客帖子都是公开的,因此我使用以下类覆盖博客路由(例如/ blog / myblogs-2):

class RestrictWebBLog(WebsiteBlog):
    @http.route(auth='user')
    def blogs(self):
        return super(RestrictWebBLog, self).blogs()

    @http.route(auth='user')
    def blog_post(self):
        return super(RestrictWebBLog, self).blog_post()

    @http.route(auth='user')
    def blog(self):
        return super(RestrictWebBLog, self).blog()

似乎可行,因为尝试访问任何博客时需要登录,但是输入凭据后,会出现以下错误:

错误消息:

blog() got an unexpected keyword argument 'blog'
Traceback (most recent call last):
  File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 203, in _dispatch
    result = request.dispatch()
  File "/opt/odoo/odoo/http.py", line 833, in dispatch
    r = self._call_function(**self.params)
  File "/opt/odoo/odoo/http.py", line 344, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/http.py", line 337, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/http.py", line 939, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/http.py", line 517, in response_wrap
    response = f(*args, **kw)
TypeError: blog() got an unexpected keyword argument 'blog'

1 个答案:

答案 0 :(得分:1)

我认为您必须在与原始函数相同的函数中编写参数。

例如,函数blogs()在原始函数中有更多参数,例如

def blogs(self, page=1, **post):

因此,请尝试使用原始函数中的所有参数进行定义。