Blog

How to inherit js file in odoo?

First, you define a template in your module to add your js assets located in static/src/js:


<template id="assets_backend" name="newmodulename assets" inherit_id="web.assets_backend"> <xpath expr="." position="inside"> <script type="text/javascript" src="/newmodulename/static/src/js/custom.js"></script> </xpath> </template>


Then, in your module's new js file, you extend the widget from default module like this:


odoo.define('newmodulename.newmodulename', function (require){
"use strict";
// require original module JS
var instance = openerp;

// Extend widget
instance.web.form.One2ManyListView.include({
....
your code to override here
....
});

}