Odoo Help


one2many incoming shipments

on 10/28/13, 2:25 PM 1,529 views

I'm new to OpenERP, I have following:

shipment_obj = self.pool.get('stock.picking.in').browse(cr, uid, context.get('active_id'))

this returns incoming shipment_obj, I can access fields/properties, but when I try to access one2many field "move_lines", and iterate over it, it returns None type object.

  for product in shipment_obj.move_lines:

Here is original fields from OpenERP stock.py:

'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}),
'product_id': fields.related('move_lines', 'product_id', type='many2one', relation='product.product', string='Product'),

I want to be able to get the products for this incoming shipment.

What is correct syntax to use for iterating over?

Thanks for feedback!

Abhishek H Menon
On 10/30/13, 1:53 AM

instead of using

for product in shipment_obj.move_lines:


  for product in shipment_obj[0].move_lines:

thanks for the response but none of the answers here work and to be honest they don't make any sense because browse returns one object if a single ID is passed as opposed to a list of IDs. ie: idea = self.browse(cr, uid, 42) would return the idea object, idea = self.browse(cr, uid, [42, 43, 44]) would return list of objects. browse Returns: object or list of objects requested. I figured out the problem but the answer is absolutely crazy to me at this point in time, what I posted works but requires one conditional element which as someone who is not new to programming escapes me.

on 10/30/13, 10:32 PM
Ashif Abdulrahman
On 10/29/13, 10:08 AM

you better use following,because in shipment_obj you will get a list

for product.move_lines in shipment_obj: etc..

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 10/28/13, 2:25 PM
Seen: 1529 times
Last updated: 3/16/15, 8:10 AM