Skip to content

Commit

Permalink
[IMP] crm: take highest priority when merging leads
Browse files Browse the repository at this point in the history
When merging leads final priority is currently the one of the lead considered
as the master lead. This is based on ``_sort_by_confidence_level`` who sorts
on confidence but not on priority.

We think final priority should be the highest one from merged leads. Indeed
if a top priority lead is merged into a low priority one we should not loose
the priority information. It is better to keep the final lead with an high
priority and let salesmen move it downwards.

LINKS

Task ID-2446759 (lead merge priority field management)
Task ID-2446883 (query counters fix)
PR odoo#65016
  • Loading branch information
tde-banana-odoo committed Jan 29, 2021
1 parent 3fff6f6 commit 9d09659
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions addons/crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ def _merge_get_fields_specific(self):
return {
'description': lambda fname, leads: '\n\n'.join(desc for desc in leads.mapped('description') if desc),
'type': lambda fname, leads: 'opportunity' if any(lead.type == 'opportunity' for lead in leads) else 'lead',
'priority': lambda fname, leads: max(leads.mapped('priority')) if leads else False,
}

def _merge_get_fields(self):
Expand Down
3 changes: 2 additions & 1 deletion addons/crm/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ def _get_description():
return '\n\n'.join(value for value in values if value)

def _get_priority():
return original_opp_values['priority']
values = [_find_value(lead, 'priority') for lead in leads]
return max(values)

try:
# merge process will modify opportunity
Expand Down
2 changes: 1 addition & 1 deletion addons/crm/tests/test_crm_lead_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ def test_merge_method(self):
with self.assertLeadMerged(self.lead_1, leads,
name='Nibbler Spacecraft Request',
partner_id=self.contact_company_1,
priority='0'):
priority='2'):
leads._merge_opportunity(auto_unlink=False, max_length=None)

0 comments on commit 9d09659

Please sign in to comment.