Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3173 Visualizzazioni

I suspect that I am using old API in this code block:

Model = request.registry['stock.picking']
cr, uid, context = request.cr, request.uid, request.context
fields = [ 'id' ]
current_stock_picking = Model.read(cr, uid, [int(id)], fields, context)[0]['id']


Which would be the equivalent in API 8?

The code is included in a controller, should I use any decorator for using API 8?


Avatar
Abbandona
Risposta migliore

Just change it to:

env['stock.picking'].read([int(id)], fields)[0]['id']

The values of the fields list should be other than 'id', because the field id it will always returned in the dict of result for a given id and also you have it in the var id

Avatar
Abbandona
Autore

I tried and it does not work. It returns an empty list.

Autore Risposta migliore

Thanks Axel,

I do 

env = Env(cr, uid, context)

to get env.

Any possibility to use directly env? (I am using it inside a controller)

Avatar
Abbandona

solved then?

Post correlati Risposte Visualizzazioni Attività
6
feb 16
7207
2
feb 22
5268
2
set 15
4249
0
mag 15
2882
1
lug 18
3582