将 Odoo 网站路由从 public 更新到用户时出现内部错误
Internal Error when updating Odoo website route from public to user
我正在尝试将所有博客访问限制为仅经过身份验证的用户,因为默认情况下所有博客文章都是 public,我使用以下 class 来覆盖博客路由(例如 /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'
我认为你必须在函数中编写与原始函数相同的参数。
例如函数blogs()
,在原函数中有更多的参数,比如
def blogs(self, page=1, **post):
所以尝试像在原始函数中那样定义所有参数。
我正在尝试将所有博客访问限制为仅经过身份验证的用户,因为默认情况下所有博客文章都是 public,我使用以下 class 来覆盖博客路由(例如 /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'
我认为你必须在函数中编写与原始函数相同的参数。
例如函数blogs()
,在原函数中有更多的参数,比如
def blogs(self, page=1, **post):
所以尝试像在原始函数中那样定义所有参数。