Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
Developing new module: "env" is not defined
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
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 2/5/16, 4:49 PM |
Seen: 1418 times |
Last updated: 2/5/16, 6:58 PM |