0
votes

I have the following:

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

This returns correct object, I can access properties, but when I access the O2m field "move_lines", it returns None object and cannot iterate.

Do I need special way to access the products for the specific incoming shipment?

This is in existing OpenERP:

    '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'),
3

3 Answers

0
votes

stock.picking.in , stock.picking.out and stock.picking are actually the same table stock_picking and stock.picking is considered as the base of both stock.picking.in and stock.picking.out. I think this functionality still have some issues and it is solved in openerp v8.So when you need to browse the object, use the stock.picking whether you are browsing for stock.picking.in nor stock.picking.out

0
votes

when using

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

here you will get a list of browse records, you can access the one2many field move_lines like

for shipment_id in shipment_obj:
    move_lines = shipment_id.move_lines

here you will get the move_lines of each records of the list...

0
votes

Needed to add this which solves the problem:

if context is not None and context.get('active_id'):

it is the way I thought the method was called that didn't need to check context and active_id since there would always be a context and active_id, I was wrong.