# -*- coding: utf-8 -*- ############################################################################## from openerp.osv import fields,osv class res_partner(osv.osv): _inherit = 'res.partner' def _pos_order_count(self, cr, uid, ids, field_name, arg, context=None): res = dict(map(lambda x: (x,0), ids)) try: for partner in self.browse(cr, uid, ids, context): res[partner.id] = len(partner.pos_order_ids) except: pass return res _columns = { 'pos_order_count': fields.function(_pos_order_count, string='# Pos Order', type='integer'), 'pos_order_ids': fields.one2many('pos.order', 'partner_id', 'Pos Order') } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: