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

I am trying to do this:

moves = env['stock.move'].search([('picking_id','==',current_stock_picking)])

Inside a controller, but I am getting global variable "env" is not defined. I also tried to define it via:

    env = Env(cr, uid, context)

But then I get global variable "Env" is not defined.

What is missing? Thanks.


I include full controller code:

class Binary(http.Controller):
@http.route('/web/binary/item_labels', type='http', auth="user")
@serialize_exception
def download_item_labels(self, id, **kw):

            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']
            print "current_stock_picking"
            print current_stock_picking

            env = Env(cr, uid, context)
            moves = env['stock.move'].search([('picking_id','==',current_stock_picking)])
            print "moves"
            print moves



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Make sure that you have imported the class Environment correctly. For example for your code works ok you just need to add this line at the top of the file

from openerp.api import Environment as Env
อวตาร
ละทิ้ง
ผู้เขียน

Thanks Axel,

Related Posts ตอบกลับ มุมมอง กิจกรรม
8
ก.ย. 21
18642
0
ส.ค. 18
5705
Module development แก้ไขแล้ว
1
ต.ค. 15
3422
1
เม.ย. 25
3688
3
ธ.ค. 22
11604