From a35e9858dcd96dc57d0558c4c3c0c16369f5dbc2 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 27 Jan 2015 19:13:53 +0100 Subject: [PATCH] [FIX] crm: opportunity count on partner form - When the partner is a company, the opportunity count should counts the opportunities of this company and all its contacts - When the partner is not a company, the opportunity count should only counts the opportunities of this lonely partner. opw-626609 --- addons/crm/res_partner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index 19b3ece1fe0..25020fe16b9 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -30,7 +30,11 @@ 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) + if partner.is_company: + operator = 'child_of' + else: + operator = '=' + opp_ids = self.pool['crm.lead'].search(cr, uid, [('partner_id', operator, partner.id), ('type', '=', 'opportunity'), ('probability', '<', '100')], context=context) res[partner.id] = { 'opportunity_count': len(opp_ids), 'meeting_count': len(partner.meeting_ids),