I'd need to understand what exactly you are trying to do. I can think of different options.
- Do you want to have a similar js code in your (otherwise unrelated) custom module? In that case, i think that the best way is to brutally copy the js of your interest into your custom module and adapt it to your needs.
- Do you want to change the way the existing website_sale_delivery.checkout module works? In this case you probably need to inherit the js module and change some parts in your custom module (let's say that your addon is called "my_custom_addon_name").
In any case, you need to create an "assets.xml" file in your view, and register it in the data array in the __manifest__. The assets.xml file must look like this:
<template id="my_custom_assets_view_name" name="my_custom_assets_view_name" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/my_custom_addon_name/static/src/js/my_js_module_name.js"></script>
</xpath>
</template>
hat you want to do precisely. You can find some info online about javascript inheritance in odoo, but pay attention to the odoo version because unfortunately it appears that most of the available informations online are deprecated...
The 'script' tag shall point to a js file (usually in my_custom_addon_name/static/src/js folder, you have to create the dirs yourself if they are not present). This will import the js file.
So, go on and create your js file in the my_custom_addon_name/static/src/js folder. Here you may wanto to set up some boilerplate:
odoo.define('my_custom_addon_name.my_js_module_name', function (require){
"use strict";
//your stuff here
});
Ok... now it all depends on what you want to do precisely. You can find some info online about javascript inheritance in odoo, but pay attention to the odoo version because unfortunately it appears that most of the available informations online are deprecated...
Good luck, cheers
checkout = require(website_sale_delivery.checkout);
//override the method:
checkout.include({
_onCarrierUpdateAnswer = function(result) {
//rewrite the function with your changes
}
});
EDIT:
Unfortunately i cannot test this at the moment, but maybe it's sufficient to override the function in the inherited model... like this:
odoo.define('my_custom_addon_name.my_js_module_name', function (require){
"use strict";
//require the module to modify:
var checkout = require(website_sale_delivery.checkout);
//override the method:
checkout.include({
_onCarrierUpdateAnswer : function(result) {
//rewrite the function with your changes
}
});
});
This is at least what i found trying to look for informations online... i can't assure that this will work, i'm still a noob with odoo but, well... i wish you the best!