Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3363 Переглядів

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?


Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Автор

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

Автор Найкраща відповідь

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)

Аватар
Відмінити

solved then?

Related Posts Відповіді Переглядів Дія
6
лют. 16
7471
2
лют. 22
5442
2
вер. 15
4473
0
трав. 15
3048
1
лип. 18
3731