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

If you have a given ID for a stock_picking, what should be done to get all product_id's associated to that stock_picking?    

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

You could do it like this:

prod_ids = [move.product_id.id for line in self.env['stock.move'].search([('picking_id', '=', picking_id)])]

Cheers

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

prod_ids = [move.product_id.id for line in self.env['stock.move'].search([('picking_id', '=', id)])] AttributeError: 'Binary' object has no attribute 'env' (**** this is used inside class Binary(http.Controller): *****)

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

Thanks Axel, and why do I need this in a controller method? I see that given the ID I could follow your path.


Model = request.registry['stock.picking']

cr, uid, context = request.cr, request.uid, request.context

fields = [ 'id' ]

res = Model.read(cr, uid, [int(id)], fields, context)[0]

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

I don't understand you correctly but if you need to find the product_id for a given picking_id in a controller you could do it as I show you with the registry of models. I don't know that you need it to use it in a controller when I answer you but it's the same.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 25
4886
1
thg 11 21
16725
1
thg 5 21
4114
2
thg 4 20
5299
4
thg 10 19
9913