当我尝试使用odoo控制器将记录添加到我的模型中时,出现此错误“在服务器上找不到请求的URL”

时间:2018-08-09 07:00:08

标签: python odoo odoo-10

这是我在模块控制器内部编写的

from odoo import http
from odoo.http import request
class Mylib(http.Controller):

    @http.route('/mylib/project', auth='public',method=['POST'], csrf=False)
    def fun_post(self):
              vals = {'name': 'The secret', 'author': 'shakesphere', 'year': 1661, 
             'book_copy': 12}

              return request.env['books.model'].create(vals)

运行此命令后,未添加任何记录,这可能是url问题。我不知道如何放置这条路线...我通过邮递员检查了,然后出现此错误,

" The requested URL was not found on the server.  If you entered the 
 URL manually please check your spelling and try again"

1 个答案:

答案 0 :(得分:0)

希望函数的缩进是正确的,并且在类Mylib中定义。

如果您是从外部来源调用此URL,或者没有登录系统,则如果您有多个数据库,则必须提及数据库详细信息。