[IMP] crm: show lost opportunities to merge with existing opportunities

This commit is contained in:
dut-odoo
2016-11-08 11:15:27 +01:00
committed by fwi-odoo
parent efdb5373c3
commit 42226de46e
2 changed files with 5 additions and 1 deletions
+2
View File
@@ -658,6 +658,8 @@ class Lead(FormatAddress, models.Model):
domain = partner_match_domain
if not include_lost:
domain += ['&', ('active', '=', True), ('probability', '<', 100)]
else:
domain += ['|', '&', ('type', '=', 'lead'), ('active', '=', True), ('type', '=', 'opportunity')]
return self.search(domain)
@api.multi
+3 -1
View File
@@ -122,7 +122,9 @@ class Lead2OpportunityPartner(models.TransientModel):
values['partner_id'] = self.partner_id.id
if self.name == 'merge':
leads = self.opportunity_ids.merge_opportunity()
leads = self.with_context(active_test=False).opportunity_ids.merge_opportunity()
if not leads.active:
leads.write({'active': True, 'next_activity_id': False, 'lost_reason': False})
if leads.type == "lead":
values.update({'lead_ids': leads.ids, 'user_ids': [self.user_id.id]})
self.with_context(active_ids=leads.ids)._convert_opportunity(values)