Odoo Help

Welcome!

This community 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.

0

[v9] How do I make sure my JS code runs after the code of some other module?

By
Javier Almancevo
on 1/10/16, 4:29 PM 229 views

There is a default module that makes a binding:


odoo.define('default_module', function(require) {
"use strict";
......
$('.some_class').on('change', 'some_selection', function() {
....
});
});


I need to create a module that removes that binding and adds another one, like this:

odoo.define('my_module', function (require) {
"user strict";
.....
$('.some_class').off('change', 'some_selection');
$('.some_class').on('change', 'some_selection', function() {
..... //my new code
});
});


But obviously I need to make sure that the code of my module runs after the code of the default module. I believe that adding inside my_module the line:

var default_module = require('default_module');

 will make the code inside default_module always run before the code inside my_module. Can anyone confirm this is correct? If not, can anyone explain how to do it?

Thanks,

add that module to dependency list in a __odoo__.py manifest of your module

Temur
on 1/11/16, 4:57 AM

@Temur, I have done so, but is it having the default module as a dependency in my module __odoo__.py enough to guarantee that the default module javascript will run before my module javascript? We are not talking about python code, where that would be enough, but Javascript code.

Javier Almancevo
on 1/11/16, 7:02 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/10/16, 4:29 PM
Seen: 229 times
Last updated: 1/11/16, 6:17 AM