我正在尝试覆盖 odoo 11 中网站模块中的索引方法。
以下是我的代码
from odoo import http
from addons.website.controllers.main import Website
class Home(Website):
@http.route(['/', '/index', '/home'], type='http', website=True, auth='public')
def index(self, **kw):
super(Website, self).index(**kw)
return http.request.render('my_website.home')
我在 my_website 中创建了一个名为 home 的新模板。但是当我访问http://localhost:8069时,它正在为带有页眉和页脚的网站加载标准 odoo 模板。当我访问http://localhost:8069/index或http://localhost:8069/home时,它会抛出 404 错误。它不会把我的新模板带回家。
我已经提到了这个 SO question How to change default page of odoo with other webcontroller odoo 9.0但不起作用。