From ea54d4af9f75e518c5871213a668a9f516e56830 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 6 Jan 2015 11:31:08 +0100 Subject: [PATCH] [FIX] crm: opportunities button in partner form only count opportunities Before, all crm.lead of the partner were counted, whatever it was a lead or an opportunity, but the button opens the opportunity tree, which has a domain type = opportunity. So leads were not displayed, and the count was therefore misleading. Besides, the button is called "Opportunities", and it was misleading to count leads for a button with such a name --- addons/crm/res_partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index 718ecd929ba..19b3ece1fe0 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -30,8 +30,9 @@ class res_partner(osv.osv): # the user may not have access rights for opportunities or meetings try: for partner in self.browse(cr, uid, ids, context): + opp_ids = self.pool['crm.lead'].search(cr, uid, [('partner_id', '=', partner.id), ('type', '=', 'opportunity'), ('probability', '<', '100')], context=context) res[partner.id] = { - 'opportunity_count': len(partner.opportunity_ids), + 'opportunity_count': len(opp_ids), 'meeting_count': len(partner.meeting_ids), } except: