Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
one2many incoming shipments
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:
etc...
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!
instead of using
for product in shipment_obj.move_lines:
etc...
use,
for product in shipment_obj[0].move_lines:
etc...
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.
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.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 10/28/13, 2:25 PM |
Seen: 1529 times |
Last updated: 3/16/15, 8:10 AM |