Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
6444 Visualizzazioni

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?    

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Autore

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

Autore Risposta migliore

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]

Avatar
Abbandona

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.

Post correlati Risposte Visualizzazioni Attività
2
mag 25
4824
1
nov 21
16702
1
mag 21
4093
2
apr 20
5288
4
ott 19
9892