I am trying to get my supplier prices listed in a custom view (modified version of product_supplier_info module) but can't figure out how to pull the prices from the 'pricelist_ids' field correctly. We only have one price per supplier (no bulk price breaks), so I only need the data from the first line. Anyone know how I could pull that? Are o2m stored as arrays?
EDIT: In case anyone else is trying to do this, here is what I ended up coming up with:
from osv import osv, fields
from openerp import tools
from tools.translate import _
import openerp.addons.decimal_precision as dp
class product_supplierinfo(osv.osv):
_inherit = 'product.supplierinfo'
def _current_price(self, cr, uid, ids, field_names=None, arg=False, context=None):
if context is None:
context = {}
res = {}
for supp_nfo in self.browse(cr, uid, ids, context=context):
res[supp_nfo.id] = 0.0
if supp_nfo.pricelist_ids:
res[supp_nfo.id] = supp_nfo.pricelist_ids[0].price
return res
_columns={
'x_cur_price' : fields.function(_current_price,type='float',string="Price"),
}
product_supplierinfo()
Worked like a charm, thanks for the help everyone.