Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3157 Lượt xem

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?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả Câu trả lời hay nhất

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)

Ảnh đại diện
Huỷ bỏ

solved then?

Bài viết liên quan Trả lời Lượt xem Hoạt động
6
thg 2 16
7195
2
thg 2 22
5265
2
thg 9 15
4241
0
thg 5 15
2875
1
thg 7 18
3578