diff options
| author | Anh Thao Pham (pta) <pta@odoo.com> | 2020-08-26 08:13:24 +0000 |
|---|---|---|
| committer | Anh Thao Pham (pta) <pta@odoo.com> | 2020-08-27 14:05:04 +0000 |
| commit | e4e4ee3d03c887900983b815abc8e349359c265c (patch) | |
| tree | ac5e8b320572f4d527caf9b90c637fc89890986c /addons/crm/models | |
| parent | 70c223eebe7edfa26564598c898cb9a8541e349b (diff) | |
[FIX] crm: fix undesired opportunities via partner's smart button
- Create a Contact named "Alpha"
- Create another Contact named "Mister X" with "misterx@alpha.com" as email
- Go to CRM and create an Opportunity for Mister X
- Go to Contacts and open Alpha
The Opportunities smart button shows 0, but when clicking on it,
Mister X's Opportunity is displayed.
The Opportunity smart button displays a "crm.lead" view with a filter on partner_id.
The filter applies an "ilike" with the Contact's name on several fields of "crm.lead",
including "email_from".
As Mister X's email address contains Alpha's name, its opportunity is wrongly retrieved.
opw-2320299
closes odoo/odoo#56666
X-original-commit: 547cc14d7fc4f39a00bf7a05b781c1edfa050cf6
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
Diffstat (limited to 'addons/crm/models')
| -rw-r--r-- | addons/crm/models/res_partner.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/crm/models/res_partner.py b/addons/crm/models/res_partner.py index 8f429c888ec..fdc2cdf689e 100644 --- a/addons/crm/models/res_partner.py +++ b/addons/crm/models/res_partner.py @@ -82,3 +82,14 @@ class Partner(models.Model): 'default_partner_ids': partner_ids, } return action + + def action_view_opportunity(self): + ''' + This function returns an action that displays the opportunities from partner. + ''' + action = self.env.ref('crm.crm_lead_opportunities').read()[0] + if self.is_company: + action['domain'] = [('partner_id.commercial_partner_id.id', '=', self.id)] + else: + action['domain'] = [('partner_id.id', '=', self.id)] + return action |
