PY code
def js_positions(self):
vehicle_obj =self.env['fleet.vehicle']
vehicle_args =[]
return_positions ={}
vehicle_data =vehicle_obj.search(vehicle_args, offset=0, limit=None, order=None)
if len(vehicle_data)>0:
for vehicle in vehicle_data:
positions_arg =[]
positions_data =self.search_read(positions_arg, offset=0, limit=1, order='devicetime DESC')
if len(positions_data)>0:
return_positions[vehicle.id] =positions_data[0]
return return_positions
JS Code
rpc.query({
model: 'MYMODEL',
method: 'js_positions',
fields: ['deviceid','devicetime'],
limit: 10,
})
.then(function (result)
{
//console.log("Device " + result);
});
Odoo v11 Error
File "/usr/lib/python3/dist-packages/odoo/api.py", line 699, in call_kw return call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 686, in call_kw_multi ids, args = args[0], args[1:]
IndexError: list index out of range