如何在 OpenERP V8 (Odoo) 中继承未命名的 class 并覆盖其方法

How inherit to unnamed class and Override its method in OpenERP V8 (Odoo)

我想继承名为 AuthSignupHome 的 class 以覆盖其名为 do_signup 的方法,但是此 class 没有 _name 属性。

AuthSignupHomeclass的路由是:odoo/addons/auth_signup/controllers/main.py

我读到要重写一个方法,有必要重新定义 class' 属性,但是它没有...而且我不需要它,对此我有点困惑!

我是 odoo 的新手,请简单说明,我该怎么做?

编辑:它是一个网络控制器,我正在阅读继承和覆盖,谁能给我一个指导方针吗?

我解决了,首先构建一个网络模块,然后 main.py 控制器

class MyClass(openerp.addons.auth_signup.controllers.main.AuthSignup):

里面我覆盖了方法

def do_signup(self, qcontext):

,仅此而已:)

在旧的 OpenERP 文档中找到这个:http://odoo-documents.readthedocs.org/en/latest/reference/http.html

class MyController(openerp.http.Controller):
    @route('/some_url', auth='public')
    def handler(self):
        return stuff()

要覆盖控制器,继承其 class 并覆盖相关方法,必要时重新公开它们:

class Extension(MyController):
    @route()
    def handler(self):
        do_before()
        return super(Extension, self).handler()

decorating with route() is necessary to keep the method (and route) visible: if the method is redefined without decorating, it will be “unpublished”

the decorators of all methods are combined, if the overriding method’s decorator has no argument all previous ones will be kept, any provided argument will override previously defined ones