跳至內容
選單
此問題已被標幟
2 回覆
3365 瀏覽次數

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?

相關帖文 回覆 瀏覽次數 活動
6
2月 16
7474
2
2月 22
5442
2
9月 15
4477
0
5月 15
3048
1
7月 18
3733