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

2.6k views Asked by At

I want to inherit to the class called AuthSignupHome for override its method called do_signup, but this class haven't a _name attribute.

The route of the AuthSignupHome class is: odoo/addons/auth_signup/controllers/main.py

I readed to override a method, it's necessary re-define the class' attributes, but it haven...and I don't need it, I'm a little confused for that!

I'm new in odoo, please clarify on easy way, how can I do it?

EDIT: It's a web controller, I was reading the inherit and override from, can anyone provide me a guideline to do that?

2

There are 2 answers

0
Juan Salcedo On BEST ANSWER

I solved it, first building a web module, and the main.py controller

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

inside I override the method

def do_signup(self, qcontext):

, thats all :)

0
Hieu On

Found this in the old the old OpenERP document: 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()

To override a controller, inherit from its class and override relevant methods, re-exposing them if necessary:

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