Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to modify existing widgets and classes in OpenERP/Odoo ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 760
    Comment on it

    In the class system of the Odoo web framework allows direct modification of existing classes using the include() method.
    This system is similar to the inheritance mechanism, except it will alter the target class in-place instead of creating a new class,for example code is like below.

    var TestClass = instance.web.Class.extend({
        testMethod: function() {
            return "hello";
        },
    });
    
    TestClass.include({
        testMethod: function() {
            return this._super() + " world";
        },
    });
    
    console.log(new TestClass().testMethod());
    

    Note-In that case, this._super() will call the original implementation of a method being replaced/redefined.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: