[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
This commit is contained in:
parent
c772b3db9a
commit
a35e9858dc
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue