コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
6453 ビュー

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?    

アバター
破棄
最善の回答

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

アバター
破棄
著作者

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): *****)

著作者 最善の回答

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]

アバター
破棄

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.

関連投稿 返信 ビュー 活動
2
5月 25
4849
1
11月 21
16715
1
5月 21
4103
2
4月 20
5289
4
10月 19
9900