Odoo Help

0

0
1 Answer
0
Daniele Morelli
10/15/18, 9:12 AM

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!


5 Comments
PUNT SISTEMES SLU, Isaac
10/15/18, 9:29 AM

Hi, I need change $pay_button.prop('disabled', false) by $pay_button.prop('disabled', true);

I try with include, extends, by not work.

Daniele Morelli
10/15/18, 10:52 AM

Hi, i edited my answer with some other details... best regards

PUNT SISTEMES SLU, Isaac
10/15/18, 11:29 AM

Hello Daniele, I try your solution, but not work. I think that your solution I the tried or similar, but not work for me.

Daniele Morelli
10/16/18, 4:33 AM

I'm sorry to hear that... gonna try some experiments as soon as i can; if i come up with a solution i'll surely let you know!

PUNT SISTEMES SLU, Isaac
10/16/18, 4:37 AM

Thanks Daniele!

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now