Taking in consideration the following code, how can I populate the 'lat' and 'lng' variables? I can only get a value inside the "query". :|
var lat=0;
var lng=0
if (coords){
var coords_obj = new openerp.Model('gps_base.coords');
coords_obj.query(['latitude_aux', 'longitude_aux'])
.filter([['id', '=', coords]])
.limit(1)
.all().then(function (result) {
_.each(result, function(item) {
lat=item.latitude_aux;
lng=item.longitude_aux;
});
});
alert(lat); //shows 'undefined'
}