res_partner.py 784 B

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