[FIX] code cleanup (addon crm_claim)
improves the _claim_count method by removing try/except/pass and by using search_count. Also, removes the now useless one2many field claims_ids (strangely, it was defined before _claim_count, but was not used. bzr revid: ged@openerp.com-20140507081723-7pi1t33xxjb6hbwy
This commit is contained in:
parent
0a9a393010
commit
b08e0b0fe1
|
@ -191,15 +191,13 @@ class crm_claim(osv.osv):
|
|||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
def _claim_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=context):
|
||||
res[partner.id] = len(partner.claims_ids)
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
Claim = self.pool['crm.claim']
|
||||
return {
|
||||
partner_id: Claim.search_count(cr,uid, [('partner_id', '=', partner_id)], context=context)
|
||||
for partner_id in ids
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'claims_ids': fields.one2many('crm.claim', 'partner_id', 'Claims'),
|
||||
'claim_count': fields.function(_claim_count, string='# Claims', type='integer'),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue