Odoo Help

Welcome!

This community 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.

0

How can you get a list of all product_id's associated to a given a stock_picking id?

By
E.M.
on 1/27/16, 3:14 PM 460 views

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?    

1

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 1/27/16, 4:11 PM

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

E.M.
on 1/28/16, 4:27 AM
0
E.M.
On 1/28/16, 4:13 AM

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.

Axel Mendoza
on 1/28/16, 9:38 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/27/16, 3:14 PM
Seen: 460 times
Last updated: 1/28/16, 4:13 AM