Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: CRM

Entity: res.partner

Compute Method: _compute_opportunity_count

View 18.0 View 20.0
Inputs Method Outputs
  • id
  • parent_id
self.opportunity_count = 0
- if not self.env.user._has_group('sales_team.group_sale_salesman'):
+ if not self.env.user.has_group('sales_team.group_sale_salesman'):
            return
- all_partners = self.with_context(active_test=False).search_fetch(
-             [('id', 'child_of', self.ids)], ['parent_id'],
-         )
opportunity_data = self.env['crm.lead'].with_context(active_test=False)._read_group(
-             domain=[('partner_id', 'in', all_partners.ids)],
+             domain=self._get_contact_opportunities_domain(),
            groupby=['partner_id'], aggregates=['__count']
        )
- self_ids = set(self._ids)
+ current_pids = set(self._ids)
for partner, count in opportunity_data:
            while partner:
-                 if partner.id in self_ids:
+                 if partner.id in current_pids:
                    partner.opportunity_count += count
                partner = partner.parent_id
  • opportunity_count

Back to entity