I'm writing a Javascript function that will return a number as result. This is my code:
get_tiquete_hacienda: function (){
var myconsecutivo = 0;
var rpc2 = require('web.rpc');
rpc2.query({
model: 'pos.order',
method: 'compute_sales_bsi'
}).then(function(res) {
myconsecutivo = res;
console.log('soy el otro: ' + myconsecutivo);
});
return myconsecutivo;
}
If i look at the console, "soy el otro:" renders the correct value but return myconsecutivo is undefined
Why is this the case?