تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6440 أدوات العرض

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
مايو 25
4793
1
نوفمبر 21
16691
1
مايو 21
4084
2
أبريل 20
5282
4
أكتوبر 19
9882