Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3441 มุมมอง

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
7608
2
ก.พ. 22
5538
api.onchange v8 doesnt work แก้ไขแล้ว
2
ก.ย. 15
4611
0
พ.ค. 15
3108
1
ก.ค. 18
3793