[WIP] fix the duplicate partner creation when converting a lead to opportunity
lp bug: https://launchpad.net/bugs/1065751 fixed bzr revid: abo@openerp.com-20121106175142-eoozcwd8xz5412mk
This commit is contained in:
parent
aabb0f38fa
commit
efd48ffbef
|
@ -610,9 +610,9 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
}
|
||||
|
||||
def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None):
|
||||
partner = self.pool.get('res.partner')
|
||||
customer = False
|
||||
if partner_id:
|
||||
partner = self.pool.get('res.partner')
|
||||
customer = partner.browse(cr, uid, partner_id, context=context)
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
if lead.state in ('done', 'cancel'):
|
||||
|
|
|
@ -105,6 +105,7 @@ class crm_lead2opportunity_partner(osv.osv_memory):
|
|||
context = {}
|
||||
lead = self.pool.get('crm.lead')
|
||||
res = False
|
||||
# FIXME: automatically creating a partner ?
|
||||
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
|
||||
lead_ids = vals.get('lead_ids', [])
|
||||
team_id = vals.get('section_id', False)
|
||||
|
@ -175,12 +176,19 @@ class crm_lead2opportunity_mass_convert(osv.osv_memory):
|
|||
return res
|
||||
|
||||
def _convert_opportunity(self, cr, uid, ids, vals, context=None):
|
||||
"""
|
||||
When "massively" (more than one at a time) converting leads to
|
||||
opportunities, check the salesteam_id and salesmen_ids and update
|
||||
the values before calling super.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.browse(cr, uid, ids, context=context)[0]
|
||||
salesteam_id = data.section_id and data.section_id.id or False
|
||||
salesman = []
|
||||
salesmen_ids = []
|
||||
if data.user_ids:
|
||||
salesman = [x.id for x in data.user_ids]
|
||||
vals.update({'user_ids': salesman, 'section_id': salesteam_id})
|
||||
salesmen_ids = [x.id for x in data.user_ids]
|
||||
vals.update({'user_ids': salesmen_ids, 'section_id': salesteam_id})
|
||||
return super(crm_lead2opportunity_mass_convert, self)._convert_opportunity(cr, uid, ids, vals, context=context)
|
||||
|
||||
def mass_convert(self, cr, uid, ids, context=None):
|
||||
|
|
Loading…
Reference in New Issue