reshma s s
reshma s s

Reputation: 51

How can we inherit a JS file from one module to another JS file in another module in odoo10

I want know how a JS file in module1 can be inherited from another JS file in another module2 in odoo10.

I want to inherit a JS file named 'dialog.js'in module named "module1" to a JS file named 'script.js' which is in another module named "module2"

Upvotes: 1

Views: 852

Answers (1)

Phillip Stack
Phillip Stack

Reputation: 3378

Odoo uses a REQUIREJS style of javascript modularisation. Here is how you can create a new js module which has inherited the characteristics or another.

odoo.define('addon_name.jsmodule', function (require) {
"user strict"
    var module = require('other.module');
    module.extend({
        // Your extension here
    });
});

Now within the scope of your jsmodule you have access to all of the attributes of the other.module plus or minus your modifications.

You can see examples of this in /addons/web/static/src/js/framework/data.js this is a (to me anyway) a complex topic. There are entire university courses on javascript inheritance. I am not an expert either. In the framework directory there are many examples of class extension. This is where I would go to get a better understanding of how to inherit the properties of an existing class.

You can also review the documentation Odoo Javascript,Odoo JS Extensions

Make sure you have a cup of coffee. Enjoy!

Upvotes: 1

Related Questions